Compare two schemas of two different DB's using Diff

598 views
Skip to first unread message

Neethu Abhinav

unread,
May 22, 2018, 7:03:34 AM5/22/18
to sqlalchemy
Hi,

I have installed sqlalchemy 1.2.7, and went through the docs for sqlAlchemy Diff, but i am still confused on how to use it effectively for my requirement.

We use Oracle 12C

1. We have two databases, which have the schema in common, DB1 Schema A, DB2 Schema A
2. I want to compare these two schemas across db's to get the difference in the metadata.(eg: difference in Table columns, missing index and so on).
3. Are these possible?
4. And in the documentation, it is mentioned to use compare(uri_left, uri_right), what are these uri's and how to use them or rather create them. Please guide me through this.

Thanks,
Neethu

Simon King

unread,
May 22, 2018, 7:18:29 AM5/22/18
to sqlal...@googlegroups.com
I assume this is the tool you are talking about:

http://sqlalchemy-diff.readthedocs.io/en/latest/

The URIs it expects will be the same ones accepted by
sqlalchemy.create_engine():

http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls

Hope that helps,

Simon

Neethu Abhinav

unread,
May 22, 2018, 7:24:03 AM5/22/18
to sqlalchemy
Yes, that's the tool i am talking about

oh okay, so ideally if i pass my two connections, it will get me a difference at the whole DB level and from the result, i can segregate what i need? Sorry if i sound ignorant, i am totally new to SQLAlchemy.

Thanks,
Neethu

Neethu Abhinav

unread,
May 22, 2018, 7:26:11 AM5/22/18
to sqlalchemy
And can you also help me the imports, that is required to use this tool?

Simon King

unread,
May 22, 2018, 8:28:07 AM5/22/18
to sqlal...@googlegroups.com
(Note that sqlalchemy-diff is not part of sqlalchemy, it's a tool
built on top of it, and there may not be anyone on this list who has
ever used it)

Something like this might do what you want:

########################################
from pprint import pprint
from sqlalchemydiff import compare

DBURI1 = 'oracle://scott:ti...@127.0.0.1:1521/dbname1'
DBURI2 = 'oracle://scott:ti...@127.0.0.1:1521/dbname2'

result = compare(DBURI1, DBURI2)
if result.is_match:
print('Databases are identical')
else:
print('Databases are different')
pprint(result.errors)
########################################

Simon
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages