docs: Update README.md for PostgreSQL requirement and remove SQLite references
This commit updates the README.md to reflect the requirement of PostgreSQL for both development and production environments. It clarifies the database setup instructions, removes references to SQLite, and ensures consistency in the documentation regarding database configurations. Additionally, it enhances the clarity of environment variable settings and database schema compatibility between the web and desktop versions.
This commit is contained in:
+14
-27
@@ -20,8 +20,8 @@ def get_database_url() -> str:
|
||||
db_url = os.getenv("DATABASE_URL")
|
||||
if db_url:
|
||||
return db_url
|
||||
# Default to SQLite for development
|
||||
return "sqlite:///data/punimtag.db"
|
||||
# Default to PostgreSQL for development
|
||||
return "postgresql+psycopg2://punimtag:punimtag_password@localhost:5432/punimtag"
|
||||
|
||||
|
||||
def get_auth_database_url() -> str:
|
||||
@@ -34,24 +34,17 @@ def get_auth_database_url() -> str:
|
||||
|
||||
|
||||
database_url = get_database_url()
|
||||
# SQLite-specific configuration
|
||||
connect_args = {}
|
||||
if database_url.startswith("sqlite"):
|
||||
connect_args = {"check_same_thread": False}
|
||||
|
||||
# PostgreSQL connection pool settings
|
||||
pool_kwargs = {"pool_pre_ping": True}
|
||||
if database_url.startswith("postgresql"):
|
||||
pool_kwargs.update({
|
||||
"pool_size": 10,
|
||||
"max_overflow": 20,
|
||||
"pool_recycle": 3600,
|
||||
})
|
||||
pool_kwargs = {
|
||||
"pool_pre_ping": True,
|
||||
"pool_size": 10,
|
||||
"max_overflow": 20,
|
||||
"pool_recycle": 3600,
|
||||
}
|
||||
|
||||
engine = create_engine(
|
||||
database_url,
|
||||
future=True,
|
||||
connect_args=connect_args,
|
||||
**pool_kwargs
|
||||
)
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, future=True)
|
||||
@@ -69,22 +62,16 @@ def get_db() -> Generator:
|
||||
# Auth database setup
|
||||
try:
|
||||
auth_database_url = get_auth_database_url()
|
||||
auth_connect_args = {}
|
||||
if auth_database_url.startswith("sqlite"):
|
||||
auth_connect_args = {"check_same_thread": False}
|
||||
|
||||
auth_pool_kwargs = {"pool_pre_ping": True}
|
||||
if auth_database_url.startswith("postgresql"):
|
||||
auth_pool_kwargs.update({
|
||||
"pool_size": 10,
|
||||
"max_overflow": 20,
|
||||
"pool_recycle": 3600,
|
||||
})
|
||||
auth_pool_kwargs = {
|
||||
"pool_pre_ping": True,
|
||||
"pool_size": 10,
|
||||
"max_overflow": 20,
|
||||
"pool_recycle": 3600,
|
||||
}
|
||||
|
||||
auth_engine = create_engine(
|
||||
auth_database_url,
|
||||
future=True,
|
||||
connect_args=auth_connect_args,
|
||||
**auth_pool_kwargs
|
||||
)
|
||||
AuthSessionLocal = sessionmaker(bind=auth_engine, autoflush=False, autocommit=False, future=True)
|
||||
|
||||
Reference in New Issue
Block a user