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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 995f3f69c37f092580c94196774b7e483fcee68d7f0fc0083f59d525b884ec89 |
|
MD5 | b1a47d9c2597bb58a2fa89923634ea3a |
|
BLAKE2b-256 | 6ee4049096bfe7a6f57949a09a1527866d90101f3779bf7f1d44a76d05eae1d0 |
Close
Hashes for sqlalchemy_timescaledb-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 097b4cbc5e41810197263a0d8de0cbb34850dbf38940c55541ab2efc0eca5207 |
|
MD5 | 99fb64d9f100af17ac459403926de667 |
|
BLAKE2b-256 | dd46f737949b54fce89ad59d54e63b3c1847d96c3f12bf6e4689691ee87ed6c4 |