Get a read-only connection pool to Supabase.
()
| 91 | |
| 92 | |
| 93 | def get_supabase_pool() -> Any: |
| 94 | """Get a read-only connection pool to Supabase.""" |
| 95 | global _supabase_pool |
| 96 | |
| 97 | host = os.getenv('SUPABASE_HOST') |
| 98 | port = os.getenv('SUPABASE_PORT') |
| 99 | database = os.getenv('SUPABASE_DATABASE') |
| 100 | user = os.getenv('SUPABASE_USER') |
| 101 | password = os.getenv('SUPABASE_PASSWORD') |
| 102 | |
| 103 | if _supabase_pool is None: |
| 104 | _supabase_pool = psycopg_pool.AsyncConnectionPool( |
| 105 | f"postgresql://{user}:{password}@{host}:{port}/{database}", |
| 106 | min_size=SUPABASE_MIN_POOL_SIZE, |
| 107 | max_size=SUPABASE_MAX_POOL_SIZE, |
| 108 | # configure=lambda c: c.execute("SET default_transaction_read_only = on") |
| 109 | ) |
| 110 | return _supabase_pool |
| 111 | |
| 112 | |
| 113 | async def close_supabase_pool() -> None: |
no outgoing calls
no test coverage detected
searching dependent graphs…