File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 49
49
from mcpgateway .config import settings
50
50
from mcpgateway .types import ResourceContent
51
51
52
+ base_connect_args = {}
53
+ # Add the SQLite-only flag when appropriate
54
+ if settings .database_url .startswith ("sqlite" ):
55
+ base_connect_args ["check_same_thread" ] = False
56
+ elif settings .database_url .startswith ("postgres" ):
57
+ base_connect_args = {
58
+ "keepalives" : 1 ,
59
+ "keepalives_idle" : 30 ,
60
+ "keepalives_interval" : 5 ,
61
+ "keepalives_count" : 5 ,
62
+ }
63
+
52
64
# Create SQLAlchemy engine with connection pooling
53
65
engine = create_engine (
54
66
settings .database_url ,
57
69
max_overflow = settings .db_max_overflow ,
58
70
pool_timeout = settings .db_pool_timeout ,
59
71
pool_recycle = settings .db_pool_recycle ,
60
- connect_args = {
61
- "keepalives" : 1 ,
62
- "keepalives_idle" : 30 ,
63
- "keepalives_interval" : 5 ,
64
- "keepalives_count" : 5 ,
65
- }
66
- # connect_args={"check_same_thread": False} if settings.database_url.startswith("sqlite") else {},
72
+ connect_args = base_connect_args
67
73
)
68
74
69
75
# Session factory
You can’t perform that action at this time.
0 commit comments