Esempio n. 1
0
    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
Esempio n. 2
0
 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'])
Esempio n. 3
0
    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)
Esempio n. 4
0
    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))
Esempio n. 5
0
def main():
    server_name = CathubPostgreSQL().server_name
    db = ase.db.connect(server_name)
    return db
Esempio n. 6
0
 def test6_delete_user(self):
     db = CathubPostgreSQL(user='******')
     db.delete_user('viggo')
Esempio n. 7
0
 def test5_release(self):
     with CathubPostgreSQL(user='******') as db:
         db.release(['MontoyaChallenge2015'],
                    from_schema='public',
                    to_schema='viggo')
Esempio n. 8
0
 def test4_create_user(self):
     with CathubPostgreSQL(user='******') as db:
         db.create_user('viggo', row_limit=None)
Esempio n. 9
0
def get_ase_db():
    server_name = CathubPostgreSQL().server_name
    return ase.db.connect(server_name)