Spaces:
Running
Running
Download database.py from tanbushi/free-apis-dev: direct link, hf CLI and curl.
- Browser
- Download file 631 Bytes
-
https://huggingface.co/spaces/tanbushi/free-apis-dev/resolve/main/database.py
- Command line
-
hf download hf://spaces/tanbushi/free-apis-dev/database.py
-
curl -L -o database.py https://huggingface.co/spaces/tanbushi/free-apis-dev/resolve/main/database.py
631 Bytes
| # 导入SQLAlchemy的create_engine函数 | |
| from sqlalchemy import create_engine | |
| # 导入SQLAlchemy的sessionmaker函数 | |
| from sqlalchemy.orm import sessionmaker | |
| # 导入SQLAlchemy的declarative_base函数 | |
| from sqlalchemy.ext.declarative import declarative_base | |
| # 定义SQLAlchemy数据库URL | |
| SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db" | |
| # 创建SQLAlchemy引擎实例 | |
| engine = create_engine( | |
| SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} | |
| ) | |
| # 创建会话本地实例 | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| # 创建SQLAlchemy的Base类实例 | |
| Base = declarative_base() |