Replies: 1 comment
-
Hey @Rabbonos! I'm here to help you with any issues you're experiencing. Let's tackle this together! Yes, it is possible to deploy on Streamlit. To resolve database creation/permission errors during the deployment process, you can use the Here is the relevant code snippet for creating the database and tables: def create_db_and_tables(self):
from sqlalchemy import inspect
inspector = inspect(self.engine)
table_names = inspector.get_table_names()
current_tables = ["flow", "user", "apikey"]
if table_names and all(table in table_names for table in current_tables):
logger.debug("Database and tables already exist")
return
logger.debug("Creating database and tables")
for table in SQLModel.metadata.sorted_tables:
try:
table.create(self.engine, checkfirst=True)
except OperationalError as oe:
logger.warning(f"Table {table} already exists, skipping. Exception: {oe}")
except Exception as exc:
logger.error(f"Error creating table {table}: {exc}")
raise RuntimeError(f"Error creating table {table}") from exc
# Now check if the required tables exist, if not, something went wrong.
inspector = inspect(self.engine)
table_names = inspector.get_table_names()
for table in current_tables:
if table not in table_names:
logger.error("Something went wrong creating the database and tables.")
logger.error("Please check your database settings.")
raise RuntimeError("Something went wrong creating the database and tables.")
logger.debug("Database and tables created successfully") This method checks if the required tables already exist and creates them if they do not. It also handles exceptions such as |
Beta Was this translation helpful? Give feedback.
-
Hello!
I am very sorry is it possible to deploy on streamlit ?
I am getting some database creation/permission errors , that's why I am asking.
Beta Was this translation helpful? Give feedback.
All reactions