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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c205b03fe1c7fcd4d7b572d774f525b7f80df03dc85d268636b16c65798b2e8 |
|
MD5 | 1b34c28d0893cf07c8f23817fa3f799d |
|
BLAKE2b-256 | bd88604822bcc30947644b481e2ba7e50cfcff812d1cbba38b02414bc82d34e5 |
Close
Hashes for sqlalchemy_timescaledb-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 404a0fe69ad821b27a1a1124bba7e3a15356ddf78a8ba57e935cf34e67b4885d |
|
MD5 | e531706b1bcf88d81d0cc5a04047c059 |
|
BLAKE2b-256 | 1c497c395ad5ae26ef6fabcf7c69e25062e9dd9f65b649b17fe2064ce8b46126 |