SQLAlchemyIO (saio): Module hack for autoloading table definitions as ORM
Project description
SQLAlchemyIO (saio)
Module hack for autoloading table definitions.
Also provides a helper function as_pandas to read an sqlalchemy.orm.query.Query into a (Geo)Pandas dataframe.
Usage
After
import saio
saio.register_schema("model_draft", engine)
one can import table declarations easily using
from saio.model_draft import lis_charging_poi as LisChargingPoi
Note that ipython and Jupyter Notebook, allow using <TAB> to auto-complete
table names.
The helper function as_pandas reads a query into a GeoDataFrame:
saio.register_schema("boundaries", engine)
from saio.boundaries import bkg_vg250_2_lan as BkgLan
df = saio.as_pandas(session.query(BkgLan))
df.plot()
Installation
The package is registered on pypi, so install with
pip install saio
or get it directly from github
pip install git+https://github.com/coroa/saio.git#egg=saio
Implementation details
saio.register_schema instantiates a declarative base using
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(bind=engine)
# The Base can be imported using from saio.model_draft import Base
and then whenever one imports any table from saio.model_draft, ie. by calling
from saio.model_draft import lis_charging_poi as LisChargingPoi, saio does
approximately
class LisChargingPoi(Base):
__tablename__ = 'lis_charging_poi'
__table_args__ = {'schema': 'model_draft', 'autoload': True}
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saio-0.2.1.tar.gz.
File metadata
- Download URL: saio-0.2.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fc0635c160a341ecf3a5b8d3b6bf83bf4cb7d410ecb6ec63ead1c9246808d87
|
|
| MD5 |
f2d63d2a82a4c5c898226cae4325fc68
|
|
| BLAKE2b-256 |
198aaeb8f8f712c0b26071afbeff0b66e06007d924027938a14f653d58611562
|
File details
Details for the file saio-0.2.1-py3-none-any.whl.
File metadata
- Download URL: saio-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.4.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e737f7595e938c2a19a5aca4896ac7df5834417e1be54686b926112393e6d89
|
|
| MD5 |
ddddbb98b237e4d8e16e974a85ff8216
|
|
| BLAKE2b-256 |
0dc87871e89596adb4a4096d76e057a431752e315a5319fd7c9519045e698e7c
|