SQLAlchemy ORM models for the ISPyB database
Project description
This provides a set of SQLAlchemy ORM models for the ISPyB database.
Installation
Install from pypi ispyb-models:
pip install ispyb-models
Basic Usage
from ispyb import models
dataCollection = models.DataCollection(
...
)
ses.add(dataCollection)
ses.commit()
...
datacollections = (
ses.query(
models.DataCollection
).filter(models.DataCollection.dataCollectionId == 1)
).first()
)
Manually generate the DB schema
Checkout the specific tag for a given ispyb-database
version:
$ git clone -b v1.18.1 https://github.com/ispyb/ispyb-database.git
$ # or, if you have an existing copy of the repository:
$ git checkout v1.18.1
Apply the schema patch in patches/circular_references.patch
to avoid circular foreign key references:
$ patch -p1 < ispyb-models/patches/circular_references.patch
Then run the ispyb-database
build.sh
script to generate the database:
$ sh build.sh
Generate the models with sqlacodegen
in src/ispyb/models/
:
sqlacodegen mysql+mysqlconnector://user:password@host:port/ispyb_build --noinflect --outfile _auto_db_schema.py
Do not edit the output file yourself
The resulting _auto_db_schema.py
should not be edited (other than automatic
formatting with black
or sorting of imports with isort
). All models are imported
into and accessed via the __init__.py
. Any modifications, e.g. injecting additional
relationships between models should be done here.
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
File details
Details for the file ispyb-models-1.0.5.tar.gz
.
File metadata
- Download URL: ispyb-models-1.0.5.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 011a8996b80957dcfae547084e1adb9be791236685b6b1295ea01762285b5ae8 |
|
MD5 | 42c9ac88502c490814169dad347e5fd3 |
|
BLAKE2b-256 | 4beb466eda185fd08666eda88d1ed41720679055a8fce19f67dbe67b522b0c9f |
File details
Details for the file ispyb_models-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: ispyb_models-1.0.5-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ce076d27d3c77a3ef50d63730713d61245be735c98c1756186eb2428f7a6ef |
|
MD5 | 6431b3b1f359210e5cb36a4925731187 |
|
BLAKE2b-256 | e5d8e184282c4aa52effdf8e58211b7333c5c38bae31a0298c99fe601485644a |