database_setup¶
-
MESSENGERuvvs.database_setup.
database_connect
(database=None, port=None, return_con=True)[source]¶ Return a database connection to saved atomic data Wrapper for
psycopg2.connect()
that determines database and port to use.Parameters
- database
Database to connect to. If not given, it must be supplied in the $HOME/.nexoclom configuration file.
- port
Port the database server uses. If not given, it must be supplied in the $HOME/.nexoclom configuration file.
- return_con
False to return database name and port instead of connection. Default = True
Returns
Database connection with autocommit = True unless return_con = False
Examples
>>> from atomicdataMB import database_connect >>> database, port = database_connect(return_con=False) >>> print(f'database = {database}; port = {port}') database = thesolarsystemmb; port = 5432 >>> with database_connect() as con: ... cur = con.cursor() ... cur.execute('SELECT DISTINCT species from gvalues') ... species = cur.fetchall() >>> species = [s[0] for s in species] >>> print(species) ['Ca', 'OH', 'O', 'Ti', 'C', 'Mg+', 'Na', 'Mg', 'H', 'Mn', 'He', 'Ca+', 'K', 'S']
-
MESSENGERuvvs.database_setup.
messenger_database_setup
(force=False)[source]¶ Setup the database from SQL database dump files. Repopulates the database using a SQL backup rather than the original IDL save files. See Database Fields Used by MESSENGERuvvs for a description of the tables and fields used by MESSENGERuvvs.
Parameters
- force
If True, deletes old database tables and remakes them. Default is False, which only creates the tables if necessary.
Returns
No output.