Skip to content

Commit b103e57

Browse files
authored
Merge pull request #6 from dorosch/develop
Added to README.md declarative based style for model
2 parents dd40d36 + 0e989be commit b103e57

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ Metric = Table(
3939
metadata.create_all(engine)
4040
```
4141

42+
Or using `declarative_base` style:
43+
44+
```Python
45+
import datetime
46+
47+
from sqlalchemy.orm import declarative_base
48+
from sqlalchemy import Column, Float, String, DateTime
49+
50+
Base = declarative_base()
51+
52+
class Metric(Base):
53+
__table_args__ = ({
54+
'timescaledb_hypertable': {
55+
'time_column_name': 'timestamp'
56+
}
57+
})
58+
59+
name = Column(String)
60+
value = Column(Float)
61+
timestamp = Column(
62+
DateTime(), default=datetime.datetime.now, primary_key=True
63+
)
64+
```
65+
4266
## Functions
4367

4468
Timescaledb functions implemented:

0 commit comments

Comments
 (0)