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()
)
Generate a new version
To update the models you need to run the workflow Update Models
through GitHub Actions panel.
This will create a new branch with models matching the latest DB release and create a pull request for merge this branch into main. Before merging there are some things you need to do:
- Make sure py-ispyb tests still pass with these new models
- Update
HISTORY.md
to reflect the changes - Bump version number with
bump2version
⚠️ 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.
⚠️ [for local test] Manually update 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/
:
. generate_models.sh
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-pyispyb-1.2.1.tar.gz
.
File metadata
- Download URL: ispyb-models-pyispyb-1.2.1.tar.gz
- Upload date:
- Size: 37.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17b6a13248183c8933c1bfdca9d6edc813aa15597cd1e5e53d4232793c9febbc |
|
MD5 | 56e34ea0890b25591805e8c69107df37 |
|
BLAKE2b-256 | 8a92847ebbabdac0b89a6d220daea67d9616d66790c97c955441809f032990da |
File details
Details for the file ispyb_models_pyispyb-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: ispyb_models_pyispyb-1.2.1-py3-none-any.whl
- Upload date:
- Size: 36.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be29a73b44198fbda63cbef882eb95a121f84495556060a39b5690f68d002f9f |
|
MD5 | 0dd923bc37a21c719dd64446b33c1ac3 |
|
BLAKE2b-256 | 2b7e3ddafb73971717cdb6cbe0fdc2624a9a5b62b42dec56671f688a99db0d40 |