Skip to main content

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


Download files

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

Source Distribution

ispyb-models-1.0.4.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

ispyb_models-1.0.4-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file ispyb-models-1.0.4.tar.gz.

File metadata

  • Download URL: ispyb-models-1.0.4.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

Hashes for ispyb-models-1.0.4.tar.gz
Algorithm Hash digest
SHA256 af0c823e100bba560a3ce2d694659ca2963784dc622f614b8b2c6b526463a5a8
MD5 9202e9097fac3953fcef59bde4682d4c
BLAKE2b-256 f261b967bec53f0c3e08bb4beef2e495172184fe4320b0e9aa7ef6e84afe7930

See more details on using hashes here.

File details

Details for the file ispyb_models-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: ispyb_models-1.0.4-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

Hashes for ispyb_models-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ecf4d1fee0ac201887444f3a4aa3b23d94a6b8942c7d233d91e563840abec7bd
MD5 df0874f4c305d05e267be5f4e3f1ada5
BLAKE2b-256 21b7e9ceb9adc68d3e49e9205b0b9363c99b639aec6ec76c40e5e36916589839

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