Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
adapter = PostgreSQLAdapter(dsn=dsn, options=options)
rs = RelStorage(adapter=adapter, options=options)
db = DB(rs)
try:
conn = db.open()
rootobj = conn.root()
if not IDatabase.providedBy(rootobj):
alsoProvides(rootobj, IDatabase)
transaction.commit()
except: # noqa
pass
finally:
rootobj = None
conn.close()
db.close()
rs = RelStorage(adapter=adapter, options=options)
db = RequestAwareDB(rs, **config)
return Database(key, db)
def RelStorageConfigurationFactory(key, dbconfig):
if not RELSTORAGE:
raise Exception("You must install the relstorage package before you can use "
"it as a dabase adapter.")
config = dbconfig.get('configuration', {})
options = Options(**dbconfig['options'])
if dbconfig['type'] == 'postgres':
from relstorage.adapters.postgresql import PostgreSQLAdapter
dsn = "dbname={dbname} user={user} host={host} password={password} port={port}".format(**dbconfig['dsn']) # noqa
adapter = PostgreSQLAdapter(dsn=dsn, options=options)
rs = RelStorage(adapter=adapter, options=options)
db = DB(rs)
try:
conn = db.open()
rootobj = conn.root()
if not IDatabase.providedBy(rootobj):
alsoProvides(rootobj, IDatabase)
transaction.commit()
except: # noqa
pass
finally:
rootobj = None
conn.close()
db.close()
rs = RelStorage(adapter=adapter, options=options)
db = RequestAwareDB(rs, **config)
return Database(key, db)
def factory():
adapter = adapter_factory(options)
storage = RelStorage(adapter=adapter, options=options)
if demostorage:
storage = DemoStorage(base=storage)
return storage
return factory, unused