Commit 1e9a2b1
committed
fix(live-db): Fix three connectivity bugs in Live DB Mode
1. Replace quote_plus with quote(safe='') for URL-encoding credentials
in the connection string. SQLAlchemy decodes with urllib.parse.unquote
(not unquote_plus), so quote_plus-encoded spaces ('+') were passed
literally to psycopg2 and caused authentication failures.
2. Use a single engine.connect() context in get_external_schema() and
inspect(conn) instead of inspect(engine). In SQLAlchemy 2.0, inspect(engine)
opens a new DB connection for every reflection method call (get_table_names,
get_columns per table), leading to N+1 connection attempts. Using a
single connection context eliminates this overhead and gives a well-defined
connection lifecycle.
3. Remove pool_pre_ping=True from both get_external_schema() and
execute_sql_on_external(). These engines are created, used once, and
disposed — pool_pre_ping adds a redundant SELECT 1 round-trip before
every use. On cold Neon instances this extra round-trip consumed part of
the 10-second connect_timeout budget, causing spurious timeouts.
https://claude.ai/code/session_016qjAVBXoVuhQD9MNdHQ6Fd1 parent f73ead2 commit 1e9a2b1
3 files changed
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | | - | |
161 | | - | |
| 162 | + | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
49 | 47 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
0 commit comments