def test_sqlite_connection_from_file(self): connfile = os.path.join(TESTDATA_DIR, 'sqlite.conn') db = database_connection(conn=connfile) dbh = DatabaseHandler('sqlite', db) elements = dbh.resolve_table('elements') self.assertTrue(dbh.check_table_exists(elements)) self.assertFalse(dbh.check_table_exists('does_not_exist'))
def detect_database_table_from_file(table, constraints_path, conn=None, dbtype=None, db=None, host=None, port=None, user=None, password=None, **kwargs): """ detect using the given database table, against constraints in the .tdda file specified. Not implemented """ (table, dbtype) = parse_table_name(table, dbtype) db = database_connection(table=table, conn=conn, dbtype=dbtype, db=db, host=host, port=port, user=user, password=password) print(detect_db_table(dbtype, db, table, constraints_path, **kwargs))
def verify_database_table_from_file(table, constraints_path, conn=None, dbtype=None, db=None, host=None, port=None, user=None, password=None, **kwargs): """ Verify the given database table, against constraints in the .tdda file specified. Prints results to stdout. """ (table, dbtype) = parse_table_name(table, dbtype) db = database_connection(table=table, conn=conn, dbtype=dbtype, db=db, host=host, port=port, user=user, password=password) print(verify_db_table(dbtype, db, table, constraints_path, **kwargs))
def test_sqlite_connection_from_file(self): connfile = os.path.join(TESTDATA_DIR, 'sqlite.conn') db = database_connection(conn=connfile) dbh = DatabaseHandler('sqlite', db) elements = dbh.resolve_table('elements') self.assertTrue(dbh.check_table_exists(elements)) self.assertFalse(dbh.check_table_exists('does_not_exist'))
def discover_constraints_from_database(table, constraints_path=None, conn=None, dbtype=None, db=None, host=None, port=None, user=None, password=None, **kwargs): """ Discover constraints in the given database table. Writes constraints as JSON to the specified file (or to stdout). """ (table, dbtype) = parse_table_name(table, dbtype) db = database_connection(table=table, conn=conn, dbtype=dbtype, db=db, host=host, port=port, user=user, password=password) constraints = discover_db_table(dbtype, db, table, **kwargs) if constraints is None: # should never happen return output = constraints.to_json(tddafile=constraints_path) if constraints_path: with open(constraints_path, 'w') as f: f.write(output); else: print(output) return output
def discover_constraints_from_database(table, constraints_path=None, conn=None, dbtype=None, db=None, host=None, port=None, user=None, password=None, **kwargs): """ Discover constraints in the given database table. Writes constraints as JSON to the specified file (or to stdout). """ (table, dbtype) = parse_table_name(table, dbtype) db = database_connection(table=table, conn=conn, dbtype=dbtype, db=db, host=host, port=port, user=user, password=password) constraints = discover_db_table(dbtype, db, table, **kwargs) if constraints_path: with open(constraints_path, 'w') as f: f.write(constraints.to_json()) else: print(constraints.to_json())
def detect_database_table_from_file(table, constraints_path, conn=None, dbtype=None, db=None, host=None, port=None, user=None, password=None, **kwargs): """ detect using the given database table, against constraints in the .tdda file specified. Not implemented """ (table, dbtype) = parse_table_name(table, dbtype) db = database_connection(table=table, conn=conn, dbtype=dbtype, db=db, host=host, port=port, user=user, password=password) print(detect_db_table(dbtype, db, table, constraints_path, **kwargs))
def setUpClass(cls): dbfile = os.path.join(TESTDATA_DIR, 'example.db') cls.db = database_connection(dbtype='sqlite', db=dbfile)
def setUpClass(cls): cls.db = database_connection(dbtype='mysql') cls.dbh = DatabaseHandler('mysql', cls.db)
def setUpClass(cls): cls.db = database_connection(dbtype='postgres') cls.dbh = DatabaseHandler('postgres', cls.db)
def setUpClass(cls): cls.db = database_connection(dbtype='mongodb') cls.dbh = DatabaseHandler('mongodb', cls.db)
def setUpClass(cls): cls.db = database_connection(dbtype='postgres') cls.dbh = DatabaseHandler('postgres', cls.db)
def setUpClass(cls): dbfile = os.path.join(TESTDATA_DIR, 'example.db') cls.db = database_connection(dbtype='sqlite', db=dbfile) cls.dbh = DatabaseHandler('sqlite', cls.db)
def setUpClass(cls): db = database_connection(dbtype='mysql') cls.dbh = DatabaseHandler('mysql', db)
def setUpClass(cls): db = database_connection(dbtype='mongodb') cls.dbh = DatabaseHandler('mongodb', db)