Skip to main content

SQLAlchemyIO (saio): Module hack for autoloading table definitions

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

Until we decide to register this package with pypi and/or conda-forge, please install it directly from git using pip:

pip install git+https://github.com/coroa/saio.git#egg=saio

or add it to the environment.yaml file you are working with as

name: ...
channels:
  - [ ... ]
dependencies:
  -  [ ... ]
  - pip:
    - [ ... ]
    - 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

saio-0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

saio-0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file saio-0.2.tar.gz.

File metadata

  • Download URL: saio-0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for saio-0.2.tar.gz
Algorithm Hash digest
SHA256 b43373d2b84e524126faf1c62318d4da20becd4329021b9d7cdf32ba98a1449f
MD5 cbc4c537df17c4d53c8b760a9f0f267d
BLAKE2b-256 283ea3196723da50696486836f467f05195a4f78f3c73fc877cc9df28d40ea28

See more details on using hashes here.

File details

Details for the file saio-0.2-py3-none-any.whl.

File metadata

  • Download URL: saio-0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for saio-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d7a248ec5bf0ca1892f48c05c04ec711589011858b760295eecc625accc62617
MD5 7ad97d17f0149f598750ba6b68cfa230
BLAKE2b-256 69700085d8dd4b5fd84a527ef37705d706230696eda4765b09e2666bf456f3a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page