Additional Functionality Reference

lwreg.utils.configure_from_database(dbname=None, connection=None, dbtype=None, host=None, user=None, password=None, lwregSchema=None, cacheConnection=True)

Returns a config dict with values from the registration metadata table in the database.

Note that in order for this to work the arguments must provide whatever information is needed to connect to the database. This can be ‘connection’ with a direct connection object or ‘dbname’ and ‘dbtype’ (potentially with ‘host’, ‘user’, and ‘password’ if those are required). If you used a nondefault schema when initializing the database, you’ll also need to provide ‘lwregSchema’ here. If ‘dbtype’ is not provided, the following heuristics are used:

  • if ‘dbname’ corresponds to an existing file, then sqlite3 is used

  • if ‘host’ is provided, then postgresql is used

  • otherwise the default dbtype, currently sqlite3, is used

Parameters:
  • dbname – the name of the database (one of dbname or connection must be provided)

  • connection – a connection object (one of dbname or connection must be provided)

  • dbtype – the type of database (sqlite3 or postgresql)

  • host – the host to connect to (for postgresql)

  • user – the user to connect as (for postgresql)

  • password – the password to use (for postgresql)

  • lwregSchema – the schema name to use for the lwreg tables (for postgresql)

  • cacheConnection (bool) – Cache connection after retrieveing the config

Returns:

A config dictionary with values from the registration metadata table in the database.

Raises:

ValueError – If neither dbname nor connection is provided.

lwreg.utils.get_all_identifiers(config=None)

Returns a tuple with all of the identifiers in the database. If in molecule mode, it returns a tuple with all of the molregnos in the database. If in conformer mode, it returns a tuple of all (molregno, conf_id) tuples in the database.

Parameters:

config – Configuration dictionary.

Returns:

A tuple with all of the identifiers in the database.