How to use the relstorage.options function in RelStorage

To help you get started, we’ve selected a few RelStorage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github newtdb / db / src / newt / db / View on Github external
if options.logging_configuration.upper() in logging_levels:
        with open(options.logging_configuration) as f:
            from ZConfig import configureLoggers

    transform = options.transform
    if transform is not None:
        from .component import global_by_name
        transform = global_by_name(transform)

    jsonifier = Jsonifier(transform=transform)
    driver = relstorage.adapters.postgresql.select_driver(
    Binary = driver.Binary
    dsn = options.connection_string
    with closing(pg_connection(dsn)) as conn:
        with closing(conn.cursor()) as cursor:
            if options.nagios:
                if not table_exists(cursor, 'newt_follow_progress'):
                    print("Updater has not run")
                    return 2
                cursor.execute("select max(tid) from object_state")
                [[stid]] = cursor
                utid = follow.get_progress_tid(conn, __name__)
                if stid is None:
                    if utid == -1:
                        print("No transactions")
                        return 0
github newtdb / db / src / newt / db / View on Github external
def storage(dsn, keep_history=False, transform=None, auxiliary_tables=(), **kw):
    """Create a RelStorage storage using the newt PostgresQL adapter.

    Keyword options can be used to provide either `ZODB.DB
    options or `RelStorage
    options = relstorage.options.Options(keep_history=keep_history, **kw)
    options.transform = transform
    options.auxiliary_tables = auxiliary_tables
    return, options), options=options)
github newtdb / db / src / newt / db / View on Github external
def pg_connection(dsn, driver_name='auto'):
    """Create a PostgreSQL (not newt) database connection

    This function should be used rather than, for example, calling
    ``psycopg2.connect``, because it can use other Postgres drivers
    depending on the Python environment and available modules.
    options = relstorage.options.Options(driver=driver_name)
    driver = relstorage.adapters.postgresql.select_driver(options)
    return driver.connect(dsn)