MobilityDB extensions to SQLAlchemy
Project description
MobilityDB SQLAlchemy
This package provides extensions to SQLAlchemy for interacting with MobilityDB. The data retrieved from the database is directly mapped to time index pandas DataFrame objects. Thanks to the amazing work by MobilityDB and movingpandas teams, because of which this project exists.
Installation
The package is available on PyPI, for Python >= 3.7
pip install mobilitydb-sqlalchemy
Usage
from mobilitydb_sqlalchemy import TGeomPoint
from sqlalchemy import Column, Integer
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Trips(Base):
__tablename__ = "test_table_trips_01"
car_id = Column(Integer, primary_key=True)
trip_id = Column(Integer, primary_key=True)
trip = Column(TGeomPoint)
trips = session.query(Trips).all()
For more details, read our documentation
Contributing
Issues and pull requests are welcome.
Setup environment
First, make sure you have poetry installed Then, get the dependencies by running (in the project home directory):
poetry install
Also make sure you setup git hooks locally, this will ensure code is formatted using black before committing any changes to the repository
pre-commit install
Running Tests
Spin up a mobilitydb instance
docker volume create mobilitydb_data
docker run --name "mobilitydb" -d -p 25432:5432 -v mobilitydb_data:/var/lib/postgresql codewit/mobilitydb
Run the tests
movingpandas is an optional dependency - but to run tests you would need it. So if this is your first time rnning tests, install it by running:
# Currently installing the optional dependency of movingpandas
# using `poetry install -E movingpandas` doesn't work
# To get movingpandas use pip instead of poetry, run the following (in exact order):
poetry shell
pip install cython
pip install git+https://github.com/SciTools/cartopy.git --no-binary cartopy
pip install movingpandas
pip install rasterio --upgrade
# This is because of movingpandas depencenies rasterio, cython and cartopy:
# (1) rasterio, cython result in unresolved dependencies
# (2) cartopy is not PEP 518 compliant
# Refer: https://github.com/SciTools/cartopy/issues/1112
Now, you can actually run the tests using:
poetry run pytest
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
Hashes for mobilitydb-sqlalchemy-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c588a77b11947539e3f29d5be173f451432521cce85831b341695350eb972d87 |
|
MD5 | ae23a93aea91dd41e56d55ab79d62f7c |
|
BLAKE2b-256 | 19ca5d84c440f0b762b4a088c5178978a3c8a3c186956eb20de67fc6d3b907ad |
Hashes for mobilitydb_sqlalchemy-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fe593ba5cc1eff274ce454627aef227eb9d200f46155e5dc039956ec04c29b9 |
|
MD5 | 2f9865c6c38273899447b6646f5bfbac |
|
BLAKE2b-256 | d52a904ec43b9ebd24699a18e2136da73faf78f95b489d7739457492978726b5 |