user2579685
user2579685

Reputation: 429

Reflecting Oracle Global Temp Tables Using Pythons SQLAlchemy

I am using sqlalchemy and want to reflect the table structure of some global temp tables.

from sqlalchemy import MetaData
...
meta = MetaData()
meta.reflect(bind = engine, only = ['tt_employees'], schema = schema)

I enable 'echo=True' when establishing the connection:

db_engine = create_engine(engine.url.URL(**params), echo=self._echo)

I can reflect all tables except for the global temp tables. This is because of the way sqlalchemy looks for the tables in the reflect():

INFO sqlalchemy.engine.base.Engine
SELECT table_name 
FROM all_tables 
WHERE nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX') 
AND OWNER = :owner 
AND IOT_NAME IS NULL 
AND DURATION IS NULL

The duration of the Oracle Global Temp Tables is 'SYS$SESSION' which is why no global temp tables reflect.

Version Info

Is there anything I can do about this?

Upvotes: 3

Views: 354

Answers (1)

user2579685
user2579685

Reputation: 429

Appending to metadata via MetaData.Tables() appears to work but guessing there is a better solution:

    Test = [sqlalchemy.Table(t, meta, autoload=True, autoload_with=_engine, schema=_schema)
        for t in schedule.tables.values]

Upvotes: 0

Related Questions