SQLAlchemy MetaData.reflect does not find tables in Oracle db

I am trying to reverse engineer an existing Oracle schema into some declarative SQLAlchemy models. My problem is that when I use MetaData.reflect , it does not find the tables in my schema, but just a global tempo table. However, I can query other tables.

I am using SQLAlchemy 0.7.8, CentOS 6.2 x86_64, python 2.6, cx_Oracle 5.1.2 and Oracle 11.2.0.2 Express Edition. Here is a brief example of what I'm talking about:

 >>> import sqlalchemy >>> engine = sqlalchemy.create_engine('oracle+cx_oracle://user: pass@localhost /xe') >>> md = sqlalchemy.MetaData(bind=engine) >>> md.reflect() >>> md.tables immutabledict({u'my_gtt': Table(u'my_gtt', MetaData(bind=Engine(oracle+cx_oracle://user: pass@localhost /xe)), Column(u'id', NUMBER(precision=15, scale=0, asdecimal=False), table=<my_gtt>), Column(u'parent_id', NUMBER(precision=15, scale=0, asdecimal=False), table=<my_gtt>), Column(u'query_id', NUMBER(precision=15, scale=0, asdecimal=False), table=<my_gtt>), schema=None)}) >>> len(engine.execute('select * from my_regular_table').fetchall()) 4 
+2
source share
1 answer

Thanks to the quick help from @zzzeek, ​​I discovered (using the echo='debug' argument for create_engine ) that my problem is because the tables belong to the old user, even if the current user can access them from the default scheme, which does not require explicit synonyms .

+1
source

Source: https://habr.com/ru/post/974221/


All Articles