A SQLAlchemy dialect for TimescaleDB
Project description
SQLAlchemy TimescaleDB
This is the TimescaleDB dialect driver for SQLAlchemy. Drivers psycopg2
and asyncpg
are supported.
Install
$ pip install sqlalchemy-timescaledb
Usage
Adding to table timescaledb_hypertable
option allows you to configure the hypertable parameters:
import datetime
from sqlalchemy import create_engine, MetaData
from sqlalchemy import Table, Column, Integer, String, DateTime
engine = create_engine('timescaledb://user:password@host:port/database')
metadata = MetaData()
metadata.bind = engine
Metric = Table(
'metric', metadata,
Column('name', String),
Column('value', Integer),
Column('timestamp', DateTime(), default=datetime.datetime.now),
timescaledb_hypertable={
'time_column_name': 'timestamp'
}
)
metadata.create_all(engine)
Functions
Timescaledb functions implemented:
first(value, time)
func.first(Metric.value, Metric.timestamp)
last(value, time)
func.last(Metric.value, Metric.timestamp)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sqlalchemy-timescaledb-0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1390028bd2f7e9d5047bac05281fb34a5d21d601e65fb309447253ad53593bb3 |
|
MD5 | a30841ffc592fae955ea20cfa16ae6e1 |
|
BLAKE2b-256 | 574945873cafaf45279b57e6f386bd6bda4d8b199fddbb08a29cd13ff525230b |
Close
Hashes for sqlalchemy_timescaledb-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1083e0239a64cb609173abd8326045f98d1d37760d51ade50185cc58d405d994 |
|
MD5 | 85daff73299dc8166d9b23d74794c6ca |
|
BLAKE2b-256 | 9c4cfbf514ab685b45067c2814d9633296221a80b6b44ea8ab1443488a045c35 |