Download telebot/plugins/sql_helper/__init__.py from thenamk3/cc: direct link, hf CLI and curl.
- Browser
- Download file 714 Bytes
-
https://huggingface.co/spaces/thenamk3/cc/resolve/main/telebot/plugins/sql_helper/__init__.py
- Command line
-
hf download hf://spaces/thenamk3/cc/telebot/plugins/sql_helper/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/thenamk3/cc/resolve/main/telebot/plugins/sql_helper/__init__.py
714 Bytes
| import os | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker, scoped_session | |
| # the secret configuration specific things | |
| from telebot.telebotConfig import Var | |
| def start() -> scoped_session: | |
| engine = create_engine(Var.DB_URI) | |
| BASE.metadata.bind = engine | |
| BASE.metadata.create_all(engine) | |
| return scoped_session(sessionmaker(bind=engine, autoflush=False)) | |
| try: | |
| BASE = declarative_base() | |
| SESSION = start() | |
| except AttributeError as e: | |
| # this is a dirty way for the work-around required for #23 | |
| print("DB_URI is not configured. Features depending on the database might have issues.") | |
| print(str(e)) | |