Skip to content

Commit 7aa8b40

Browse files
committed
🗃️ Fix issues with schema caching
1 parent c304c87 commit 7aa8b40

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/database/DB_Config.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,11 @@ def create_connection(
1818
user: Optional[str] = None,
1919
password: Optional[str] = None
2020
) -> Optional[Union[sqlite3.Connection, psycopg2.extensions.connection]]:
21-
"""
22-
Create or connect to a database.
21+
global _schema_cache
2322

24-
Parameters:
25-
- db_name (str): Name of the database.
26-
- db_type (str): Type of the database ('sqlite' or 'postgresql').
27-
- host (Optional[str]): Host address (for PostgreSQL).
28-
- user (Optional[str]): Username (for PostgreSQL).
29-
- password (Optional[str]): Password (for PostgreSQL).
23+
# Reset schema cache when using a new database
24+
_schema_cache = {}
3025

31-
Returns:
32-
- Optional[Connection]: Database connection object or None if connection fails.
33-
"""
3426
try:
3527
if db_type.lower() == 'postgresql':
3628
conn = psycopg2.connect(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy