Interaction with the variety of databases used in SDSS operations is managed via the
sdssdb package. Full documentation is provided on readthedocs and the source code is managed on GitHub.
sdssdb is available from PyPi and can be installed via pip:
pip install sdssdb
A variety of connection profiles are distributed as part of
sdssdb. When run on an SDSS server, e.g. at APO, LCO, or Utah, sdssdb checks the server’s domain name (FQDN) and selects the appropriate connection profile, allowing connections automatically in the background.
Users preferring to use their local machine with a tunnel to a database server can use the
>>> local_db = PeeWeeDatabaseConnection(profile='local') >>> local_db.connect('targetdb')
More information is provided in the official documentation.
The primary function of
sdssdb is to provide ORM model classes for Python users. The majority of ORM model classes provided are written for Peewee, though some SQL Alchemy model classes are provided as well. These model classes allow users to query, insert, and delete records in Postgresql operations databases using Python.
>>> import sdssdb.peewee.sdss5db.targetdb as targetdb >>> Field = targetdb.Field >>> circumpolar = Field.select().where(Field.deccen > 85).execute() >>> print(len(circumpolar)) 48