python - Creating table in SQLAlchemy from two different py files -


i have 2 python files, data.py , sql.py, , i'm trying achieve sqlalchemy create database table, name of database taken data.py

ie: database name taken .py file.

code in data.py

class ddd():     which_mkt = 'us, hk'     # user input     mkt = input("choose value? [" + which_mkt + "]").upper()     t = os.chdir(directorylistings.t_dir) # check in folder if file exist      if os.path.isfile(t):         # code create .db database file mkt name.  

code in sql.py

# create database engine engine = create_engine(r"sqlite:///data\\" + z + ".db", echo=true) base = declarative_base()  class gott(base):     __tablename__ = 'country'     id = column(integer, primary_key=true)     country = column(string(255))      def __init__(self, country):         self.country = country  base.metadata.create_all(engine) 

so, in sql.py, z supposed variable name of database taken data.py

i hope explanation clear. how should done?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -