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

Note: sdssdb is designed to work with the postgresql used for SDSS operations. For browsing SDSS data releases, see CAS Jobs.

Database Connections

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 profile

>>> local_db = PeeWeeDatabaseConnection(profile='local')
>>> local_db.connect('targetdb')

More information is provided in the official documentation.

Model Classes

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 = > 85).execute()
>>> print(len(circumpolar))

Many more detailed examples using sdssdb can be found in various SDSS packages used for operations such as roboscheduler, kronos, jaeger, or mugatu.

Back to Top