Name | sqlalchemy-timescaledb JSON |
Version |
0.4.1
JSON |
| download |
home_page | |
Summary | A SQLAlchemy dialect for TimescaleDB |
upload_time | 2023-07-03 11:15:28 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# SQLAlchemy TimescaleDB
[][1]
[][2]
[][3]
[][4]
This is the TimescaleDB dialect driver for SQLAlchemy. Drivers `psycopg2` and `asyncpg` are supported.
## Install
```bash
$ pip install sqlalchemy-timescaledb
```
## Usage
Adding to table `timescaledb_hypertable` option allows you to configure the [hypertable parameters][5]:
```Python
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)
```
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
)
```
## Parameters
* [chunk_time_interval](6)
## Functions
Timescaledb functions implemented:
### [first(value, time)][7]
```Python
func.first(Metric.value, Metric.timestamp)
```
### [last(value, time)][8]
```Python
func.last(Metric.value, Metric.timestamp)
```
[1]: https://badge.fury.io/py/sqlalchemy-timescaledb
[2]: https://github.com/dorosch/sqlalchemy-timescaledb/actions/workflows/tests.yml
[3]: https://codecov.io/gh/dorosch/sqlalchemy-timescaledb
[4]: https://pepy.tech/project/sqlalchemy-timescaledb
[5]: https://docs.timescale.com/api/latest/hypertable/create_hypertable/#optional-arguments
[6]: https://docs.timescale.com/api/latest/hypertable/set_chunk_time_interval/
[7]: https://docs.timescale.com/api/latest/hyperfunctions/first/
[8]: https://docs.timescale.com/api/latest/hyperfunctions/last/
Raw data
{
"_id": null,
"home_page": "",
"name": "sqlalchemy-timescaledb",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Andrei Kliatsko <andrey.daraschenka@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8e/f4/a06d88278eae468692667a1bf693212f0cb0d23cf1216d32f22cc006861a/sqlalchemy-timescaledb-0.4.1.tar.gz",
"platform": null,
"description": "# SQLAlchemy TimescaleDB\n\n[][1]\n[][2]\n[][3]\n[][4]\n\nThis is the TimescaleDB dialect driver for SQLAlchemy. Drivers `psycopg2` and `asyncpg` are supported.\n\n## Install\n\n```bash\n$ pip install sqlalchemy-timescaledb\n```\n\n## Usage\n\nAdding to table `timescaledb_hypertable` option allows you to configure the [hypertable parameters][5]:\n\n```Python\nimport datetime\nfrom sqlalchemy import create_engine, MetaData\nfrom sqlalchemy import Table, Column, Integer, String, DateTime\n\nengine = create_engine('timescaledb://user:password@host:port/database')\nmetadata = MetaData()\nmetadata.bind = engine\n\nMetric = Table(\n 'metric', metadata,\n Column('name', String),\n Column('value', Integer),\n Column('timestamp', DateTime(), default=datetime.datetime.now),\n timescaledb_hypertable={\n 'time_column_name': 'timestamp'\n }\n)\n\nmetadata.create_all(engine)\n```\n\nOr using `declarative_base` style:\n\n```Python\nimport datetime\n\nfrom sqlalchemy.orm import declarative_base\nfrom sqlalchemy import Column, Float, String, DateTime\n\nBase = declarative_base()\n\nclass Metric(Base):\n __table_args__ = ({\n 'timescaledb_hypertable': {\n 'time_column_name': 'timestamp'\n }\n })\n\n name = Column(String)\n value = Column(Float)\n timestamp = Column(\n DateTime(), default=datetime.datetime.now, primary_key=True\n )\n```\n\n## Parameters\n\n* [chunk_time_interval](6)\n\n## Functions\n\nTimescaledb functions implemented:\n\n### [first(value, time)][7]\n\n```Python\nfunc.first(Metric.value, Metric.timestamp)\n```\n\n### [last(value, time)][8]\n\n```Python\nfunc.last(Metric.value, Metric.timestamp)\n```\n\n\n[1]: https://badge.fury.io/py/sqlalchemy-timescaledb\n[2]: https://github.com/dorosch/sqlalchemy-timescaledb/actions/workflows/tests.yml\n[3]: https://codecov.io/gh/dorosch/sqlalchemy-timescaledb\n[4]: https://pepy.tech/project/sqlalchemy-timescaledb\n[5]: https://docs.timescale.com/api/latest/hypertable/create_hypertable/#optional-arguments\n[6]: https://docs.timescale.com/api/latest/hypertable/set_chunk_time_interval/\n[7]: https://docs.timescale.com/api/latest/hyperfunctions/first/\n[8]: https://docs.timescale.com/api/latest/hyperfunctions/last/\n",
"bugtrack_url": null,
"license": "",
"summary": "A SQLAlchemy dialect for TimescaleDB",
"version": "0.4.1",
"project_urls": {
"Homepage": "https://github.com/dorosch/sqlalchemy-timescaledb"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c3e42a5c5cdd2b60574547c5b61699826358e6d41005ae72caf71ff1496e36ce",
"md5": "fc8d0a46de1be1adc4f5642c7ecaade6",
"sha256": "c2111a3c8f5f141bbe34a33319926a1427dc6bd8039a2fbbca1965894a1f3416"
},
"downloads": -1,
"filename": "sqlalchemy_timescaledb-0.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fc8d0a46de1be1adc4f5642c7ecaade6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4937,
"upload_time": "2023-07-03T11:15:26",
"upload_time_iso_8601": "2023-07-03T11:15:26.990721Z",
"url": "https://files.pythonhosted.org/packages/c3/e4/2a5c5cdd2b60574547c5b61699826358e6d41005ae72caf71ff1496e36ce/sqlalchemy_timescaledb-0.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8ef4a06d88278eae468692667a1bf693212f0cb0d23cf1216d32f22cc006861a",
"md5": "822f962b67500854cc215031273cbe25",
"sha256": "43870866c6c951a71a5e83c74580574192baaf833a514eca4855ab8c48d15e0b"
},
"downloads": -1,
"filename": "sqlalchemy-timescaledb-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "822f962b67500854cc215031273cbe25",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5078,
"upload_time": "2023-07-03T11:15:28",
"upload_time_iso_8601": "2023-07-03T11:15:28.763480Z",
"url": "https://files.pythonhosted.org/packages/8e/f4/a06d88278eae468692667a1bf693212f0cb0d23cf1216d32f22cc006861a/sqlalchemy-timescaledb-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-03 11:15:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dorosch",
"github_project": "sqlalchemy-timescaledb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sqlalchemy-timescaledb"
}