Sqlite works, made fixes in config so it becomes a basis, added a few mods on top
This commit is contained in:
parent
6c5d6b6d8a
commit
22390c1bd1
2 changed files with 4 additions and 7 deletions
|
|
@ -35,6 +35,7 @@ class Config:
|
||||||
db_port: str = os.getenv("DB_PORT", "5432")
|
db_port: str = os.getenv("DB_PORT", "5432")
|
||||||
db_user: str = os.getenv("DB_USER", "cognee")
|
db_user: str = os.getenv("DB_USER", "cognee")
|
||||||
db_password: str = os.getenv("DB_PASSWORD", "cognee")
|
db_password: str = os.getenv("DB_PASSWORD", "cognee")
|
||||||
|
sqlalchemy_logging: bool = os.getenv("SQLALCHEMY_LOGGING", True)
|
||||||
|
|
||||||
# Model parameters
|
# Model parameters
|
||||||
model: str = "gpt-4-1106-preview"
|
model: str = "gpt-4-1106-preview"
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,16 @@ def get_sqlalchemy_database_url(db_type='sqlite', db_name=config.db_name, base_p
|
||||||
raise ValueError(f"Unsupported DB_TYPE: {db_type}")
|
raise ValueError(f"Unsupported DB_TYPE: {db_type}")
|
||||||
|
|
||||||
|
|
||||||
# Example usage with a configuration file:
|
|
||||||
# config = DatabaseConfig(config_file='path/to/config.json')
|
|
||||||
# Or set them programmatically:
|
|
||||||
|
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URL = get_sqlalchemy_database_url()
|
SQLALCHEMY_DATABASE_URL = get_sqlalchemy_database_url()
|
||||||
|
|
||||||
|
|
||||||
engine = create_async_engine(
|
engine = create_async_engine(
|
||||||
SQLALCHEMY_DATABASE_URL,
|
SQLALCHEMY_DATABASE_URL,
|
||||||
pool_recycle=3600,
|
pool_recycle=3600,
|
||||||
echo=True, # Enable logging for tutorial purposes
|
echo=config.sqlalchemy_logging,
|
||||||
)
|
)
|
||||||
# Use AsyncSession for the session
|
|
||||||
|
|
||||||
AsyncSessionLocal = sessionmaker(
|
AsyncSessionLocal = sessionmaker(
|
||||||
bind=engine,
|
bind=engine,
|
||||||
class_=AsyncSession,
|
class_=AsyncSession,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue