Skip to content Skip to sidebar Skip to footer

Clear Sqlalchemy Reflection Cache

I'm using sqlalchemy's reflection tools to get a Table object. I do this because these tables are dynamic and tables/columns can change. Here's the code I'm using: def getTableByRe

Solution 1:

Pass in a newly created, fresh metadata instance.

Solution 2:

With thanks to codeape's comment above I was able to fix the problem by changing the syntax to:

defgetTableByReflection(self, tableName, metadata, engine):

    return Table(tableName, MetaData(), autoload = True, autoload_with = engine)

So passing in a new MetaData() instance each time. This probably affects performance but it's ok for me in this part of my app.

All credit to codeape

Post a Comment for "Clear Sqlalchemy Reflection Cache"