Skip to content

Commit

Permalink
Merge pull request #6 from dorosch/develop
Browse files Browse the repository at this point in the history
Added to README.md declarative based style for model
  • Loading branch information
dorosch authored Jul 3, 2023
2 parents dd40d36 + 0e989be commit b103e57
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ Metric = Table(
metadata.create_all(engine)
```

Or using `declarative_base` style:

```Python
import datetime

from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Float, String, DateTime

Base = declarative_base()

class Metric(Base):
__table_args__ = ({
'timescaledb_hypertable': {
'time_column_name': 'timestamp'
}
})

name = Column(String)
value = Column(Float)
timestamp = Column(
DateTime(), default=datetime.datetime.now, primary_key=True
)
```

## Functions

Timescaledb functions implemented:
Expand Down

0 comments on commit b103e57

Please sign in to comment.