In [ ]:
from sqlalchemy import create_engine
from data_compare.sql_database import SQLDatabase
DB_CONFIG_DICT = {
'user': 'db_user',
'password': 'db_pass123',
'host': 'localhost',
'port': 5432,
}
DB_CONN_FORMAT = "postgresql://{user}:{password}@{host}:{port}/{database}"
DBA_CONN = DB_CONN_FORMAT.format(database='db_a', **DB_CONFIG_DICT)
DBB_CONN = DB_CONN_FORMAT.format(database='db_b', **DB_CONFIG_DICT)
engine_a = create_engine(DB_CONN_FORMAT.format(database='db_a', **DB_CONFIG_DICT))
engine_b = create_engine(DB_CONN_FORMAT.format(database='db_b', **DB_CONFIG_DICT))
db_a = SQLDatabase(DBA_CONN)
db_b = SQLDatabase(DBB_CONN)
db_a.compare_schemas(db_b)
In [ ]:
db_a.differences
In [ ]:
db_a.differences['person']
In [ ]:
[t for t in db_a.differences['person'] if db_a.differences['person'][t] == {}]
In [ ]:
db_a.compare_data()
In [ ]:
db_a.update_data_to_match_comparand()
In [ ]:
In [ ]:
db_a.compare_data()