Skip to content

Commit 84f67d2

Browse files
committed
Add Supabase pooler shard option
1 parent 676313a commit 84f67d2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

sqlit/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ def main() -> int:
294294
)
295295
parser.add_argument("--supabase-region", help="Supabase region (temporary connection)")
296296
parser.add_argument("--supabase-project-id", help="Supabase project id (temporary connection)")
297+
parser.add_argument(
298+
"--supabase-aws-shard",
299+
help="Supabase pooler shard prefix (temporary connection, e.g. aws-0, aws-1)",
300+
)
297301
parser.add_argument(
298302
"--settings",
299303
metavar="PATH",

sqlit/domains/connections/providers/supabase/adapter.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ def supports_multiple_databases(self) -> bool:
2020
def connect(self, config: ConnectionConfig) -> Any:
2121
region = config.get_option("supabase_region", "")
2222
project_id = config.get_option("supabase_project_id", "")
23+
shard = config.get_option("supabase_aws_shard", "aws-0")
24+
shard = str(shard).strip() or "aws-0"
25+
if shard.startswith("aws") and not shard.startswith("aws-"):
26+
suffix = shard.removeprefix("aws")
27+
if suffix.isdigit():
28+
shard = f"aws-{suffix}"
29+
elif shard.isdigit():
30+
shard = f"aws-{shard}"
2331
transformed = config.with_endpoint(
24-
host=f"aws-0-{region}.pooler.supabase.com",
32+
host=f"{shard}-{region}.pooler.supabase.com",
2533
port="5432",
2634
username=f"postgres.{project_id}",
2735
database="postgres",

sqlit/domains/connections/providers/supabase/schema.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
placeholder="abcdefghijklmnop",
2727
required=True,
2828
),
29+
SchemaField(
30+
name="supabase_aws_shard",
31+
label="AWS Shard",
32+
placeholder="aws-0",
33+
default="aws-0",
34+
description="Pooler shard prefix (e.g. aws-0, aws-1)",
35+
),
2936
SchemaField(
3037
name="password",
3138
label="Password",

0 commit comments

Comments
 (0)