Feb-13-2019, 10:03 PM
Say for example I have a database named A and B with same table name and with different set of records. I want to compare the count of the table 1 that is present in Database A and B.
Database A has 190 tables and Database B has 190 tables with same table names. But table 1 has 40 records in Database A and table 1 in Database 2 has 30 records.
As of now I am able to do that in SQL server with this query. select (select count() from A.table1) as Count1, (select count() from B.table1) as Count2
But I am trying to do the same in Python. How can I connect to the two databases with the same conn object and use it to count the table records in different databases. I would also thankful if someone can help me to automate these for all the tables in both the databases.Thank you.
Database A has 190 tables and Database B has 190 tables with same table names. But table 1 has 40 records in Database A and table 1 in Database 2 has 30 records.
As of now I am able to do that in SQL server with this query. select (select count() from A.table1) as Count1, (select count() from B.table1) as Count2
But I am trying to do the same in Python. How can I connect to the two databases with the same conn object and use it to count the table records in different databases. I would also thankful if someone can help me to automate these for all the tables in both the databases.Thank you.