repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import os |
| #2 | |
| #3 | from dotenv import load_dotenv |
| #4 | from sqlalchemy import create_engine |
| #5 | from sqlalchemy.orm import declarative_base, sessionmaker |
| #6 | |
| #7 | # load .env file (make sure you have DATABASE_URL set) |
| #8 | load_dotenv() |
| #9 | |
| #10 | DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./openmemory.db") |
| #11 | if not DATABASE_URL: |
| #12 | raise RuntimeError("DATABASE_URL is not set in environment") |
| #13 | |
| #14 | # SQLAlchemy engine & session |
| #15 | engine = create_engine( |
| #16 | DATABASE_URL, |
| #17 | connect_args={"check_same_thread": False} # Needed for SQLite |
| #18 | ) |
| #19 | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
| #20 | |
| #21 | # Base class for models |
| #22 | Base = declarative_base() |
| #23 | |
| #24 | # Dependency for FastAPI |
| #25 | def get_db(): |
| #26 | db = SessionLocal() |
| #27 | try: |
| #28 | yield db |
| #29 | finally: |
| #30 | db.close() |
| #31 |