I wrote a module which is to create an empty database file
def create_database():
engine = create_engine(\"sqlite:///myexample.db\", echo=True)
metadata
Note that in 'Base.metadata' documentation it states about create_all:
Conditional by default, will not attempt to recreate tables already present in the target database.
And if you can see that create_all takes these arguments: create_all(self, bind=None, tables=None, checkfirst=True), and according to documentation:
Defaults to True, don't issue CREATEs for tables already present in the target database.
So if I understand your question correctly, you can just skip the condition.