I wrote a module that should create an empty database file
def create_database(): engine = create_engine("sqlite:///myexample.db", echo=True) metadata = MetaData(engine) metadata.create_all()
But in another function, I want to open the myexample.db database and create tables for it, if it does not already have this table.
EG of the first, subsequent table that I would create:
Table(Variable_TableName, metadata, Column('Id', Integer, primary_key=True, nullable=False), Column('Date', Date), Column('Volume', Float))
(Since this is initially an empty database, there will be no tables in it, but later on I can add more tables to it. What I'm trying to say.)
Any suggestions?
python sqlalchemy
jake wong
source share