def __init__(self, user='******', filename=None): if filename is not None: sql_url = 'sqlite:///' + str(filename) self.backend = 'sqlite' else: sql_url = CathubPostgreSQL(user).server_name self.backend = 'postgres' self.sql_url = sql_url self.connection = None
def test2_cli_db2server(self): from cathub.postgresql import CathubPostgreSQL from cathub.cli import db2server db = CathubPostgreSQL(user='******') con = db._connect() db._initialize(con) db.truncate_schema() runner = CliRunner() runner.invoke(db2server, ['--dbuser=postgres', 'aayush/MontoyaChallenge2015.db'])
def test7_modify_reaction(self): db = CathubPostgreSQL(user='******') id = db.check(pub_id='MontoyaChallenge2015', chemical_composition='Pt16', reactants=json.dumps({ 'N2gas': 0.5, 'star': 1.0 }), products=json.dumps({'Nstar': 1.0})) db.update_reaction(id, reaction_energy=10) db.delete_reaction(id)
def test3_upload(self): """Ensure postgres database is empty""" db = CathubPostgreSQL(user='******') con = db._connect() db._initialize(con) db.truncate_schema() con.commit() con.close() db2server.main( '{path}/aayush/MontoyaChallenge2015.db'.format(path=path), user='******') if os.path.exists( '{path}/aayush/MontoyaChallenge2015.db'.format(path=path)): os.remove( '{path}/aayush/MontoyaChallenge2015.db'.format(path=path))
def main(): server_name = CathubPostgreSQL().server_name db = ase.db.connect(server_name) return db
def test6_delete_user(self): db = CathubPostgreSQL(user='******') db.delete_user('viggo')
def test5_release(self): with CathubPostgreSQL(user='******') as db: db.release(['MontoyaChallenge2015'], from_schema='public', to_schema='viggo')
def test4_create_user(self): with CathubPostgreSQL(user='******') as db: db.create_user('viggo', row_limit=None)
def get_ase_db(): server_name = CathubPostgreSQL().server_name return ase.db.connect(server_name)