sgalchemy
sgalchemy is a SQLAlchemy-style ORM for Autodesk Flow Production Tracking. It gives pipeline code
typed entity classes reflected from your site's schema, select() queries with relationship
loaders, and a Session that keeps one object per record and sends your changes only when you call
commit(). You decide when the network is used: reading an attribute never makes a hidden provider
call.
This documentation uses SG for Flow Production Tracking, formerly named Shotgun and ShotGrid.
Why use it?
Calling the provider API directly means working with dictionaries: you choose field lists for each
find(), track which records changed, and assemble batch() requests yourself. sgalchemy handles
that bookkeeping while keeping every provider call explicit.
The SQLAlchemy concepts are familiar, but SG is not a relational database, and sgalchemy follows the provider where the two differ:
- Schema loading is explicit. Call
load_schema()before you use entity classes; sgalchemy caches the schema on disk so later runs can skip the fetch. - Queries never send pending changes.
commit()is the only write boundary. - Reading a field or relationship that a query did not load raises an error instead of calling the
network. Synchronous code can opt into
lazyload(). - A commit is atomic only when it compiles to one transactional
batch()call. Revives, thumbnail uploads, and creates that link to other new records need extra calls, so a failure can leave part of a commit applied. Sessions and writes explains how to recover.
Installation
You need Python 3.11 or newer and one compatible SG API provider. From a checkout, install sgalchemy with the extra for your provider. For Autodesk's provider, run:
python -m pip install '.[official]'
Choose exactly one extra, and replace official in the command to pick another:
officialinstalls Autodesk'sshotgun-api3for synchronous and threaded async engines.apiinstallssg-python-apifor synchronous and threaded async engines.asyncinstallssg-python-apiwith its native async client, which also supports native async engines.
If your application already supplies a compatible API client, install the base package with
python -m pip install . and install the client separately.
Quick start
This example queries in-progress shots and creates one shot. It authenticates with a session token
that your application supplies in SHOTGUN_SESSION_TOKEN; see
Connections and authentication for other credentials. Replace the site
URL and the status and code values with your studio's, and add any other fields your site requires
for a new shot. Run it against a test site: the commit creates a real record.
import os
from sgalchemy import Session, create_engine, select
engine = create_engine(
'https://example.shotgunstudio.com',
session_token=os.environ['SHOTGUN_SESSION_TOKEN'],
)
try:
engine.load_schema()
from sgalchemy.entities import Shot
with Session(engine) as session:
shots = session.scalars(select(Shot).where(Shot.sg_status_list == 'ip'))
print(f'{len(shots)} shots in progress')
new_shot = Shot.new(code='sq010_sh020')
session.add(new_shot)
session.commit()
print(new_shot)
finally:
engine.dispose()
The script prints the number of matching shots, then the new shot with its server ID, such as
Shot(id=1234, code='sq010_sh020').
load_schema() fetches the site schema, or reads a fresh cached copy, before you import entity
classes. The query does not send the pending create; session.commit() does. Leaving the with
block closes the session and discards any work you did not commit. If a commit fails after a
provider call, check what was applied before you
retry.
To give your type checker the reflected fields of Shot, generate site-specific stubs; see
typed stubs.
Documentation
| If you want to... | Read |
|---|---|
| Choose credentials and recover when SG rejects them | Connections and authentication |
| Write queries and load related entities | Queries and relationships |
| Commit changes, upload thumbnails, or use session factories | Sessions and writes |
| Recover from a failed or partial commit | Failed commits |
| Use sgalchemy from asyncio code | Async usage |
| Type-check with stubs, manage the schema cache, or test | Typing, schema cache, and testing |
| See changes by version | Changelog |
Development
See the development guide for the required tools, CI, and dependency locks. With those tools installed, run:
make setup
make check
The checks never contact a live SG site unless you configure the opt-in live test.
License
sgalchemy is available under the MIT License. It is an independent project and is not affiliated with or endorsed by Autodesk. Flow Production Tracking is a product of Autodesk, Inc.
Metadata
Release files for sgalchemy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sgalchemy-0.1.0.tar.gz | 125.4 kB | With provenance | Details for sgalchemy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sgalchemy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sgalchemy-0.1.0-py3-none-any.whl |
Total release size: 270.5 kB
Release files / sgalchemy-0.1.0.tar.gz
| Download URL | sgalchemy-0.1.0.tar.gz |
|---|---|
| Size | 125.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f301b7a22b969bd5f4a43983792b801c24567387c645b284460bccbf7e7d4ea9
|
|
BLAKE2b-256 checksum How to use checksums |
a070c595ff1234731b62b8627bfab0ca4056c674631d5806fe7ddfad9729ee51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / sgalchemy-0.1.0-py3-none-any.whl
| Download URL | sgalchemy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 145.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
589865f77b0181598064b32486a129298b05f7e5dcc4681891140f6c4a479c67
|
|
BLAKE2b-256 checksum How to use checksums |
a18a3faf23a5e30cc7b5182c38f64f4691c6a9c5b003603f89eaa51a1247d5e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for sgalchemy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sgalchemy-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.