def test_bad_connect(tmpdir): # Attemping to create file in non-existent directory should fail try: db_params = DbParams(dbtype='SQLITE', filename='/does/not/exist') with pytest.raises(ETLHelperConnectionError): connect(db_params) finally: # Restore permissions prior to cleanup os.chmod(tmpdir, 0o666)
def testdb_conn(): """Get connection to test MS SQL database.""" with connect(ORADB, 'TEST_ORACLE_PASSWORD', encoding="UTF-8", nencoding="UTF-8") as conn: yield conn
def test_connect(sqlitedb): conn = connect(sqlitedb) assert isinstance(conn, sqlite3.Connection) assert os.path.isfile(sqlitedb.filename)
def testdb_conn(sqlitedb): """Get connection to test SQLite database.""" with connect(sqlitedb) as conn: yield conn
def test_connect_wrong_password(monkeypatch): monkeypatch.setitem(os.environ, 'TEST_MSSQL_PASSWORD', 'bad_password') with pytest.raises(ETLHelperConnectionError): connect(MSSQLDB, 'TEST_MSSQL_PASSWORD')
def test_connect(): conn = connect(MSSQLDB, 'TEST_MSSQL_PASSWORD') assert isinstance(conn, pyodbc.Connection)
def testdb_fast_false_conn2(): """Get connection to test MS SQL database.""" with connect(MSSQLDB, 'TEST_MSSQL_PASSWORD', fast_executemany=False) as conn: return conn
def testdb_conn2(): """Get connection to test MS SQL database.""" with connect(MSSQLDB, 'TEST_MSSQL_PASSWORD') as conn: return conn
def test_connect(): conn = connect(ORADB, 'TEST_ORACLE_PASSWORD') assert isinstance(conn, cx_Oracle.Connection)
def testdb_conn(sqlitedb): """Get connection to test SQLite database.""" with connect(sqlitedb, detect_types=sqlite3.PARSE_DECLTYPES) as conn: # PARSE_DECLTYPES makes SQLite return TIMESTAMP columns as Python datetimes yield conn
def pgtestdb_conn(pgtestdb_params): """Get connection to test PostGIS database.""" with connect(pgtestdb_params, 'TEST_PG_PASSWORD') as conn: yield conn
def get_destination_connection(): return connect(DESTINATION_DB_PARAMS, "D_PG_PASSWORD")
def get_source_connection(): if engine == ENGINES['mysql']: return mysql_con.connect(host=SHOST, port=SPORT, user=SDBUSER, password=SDBPASS, database=SDBNAME) return connect(SOURCE_DB_PARAM, "S_PG_PASSWORD")