fromConnectionString static method
Future<SupabaseAdapter>
fromConnectionString(
- String connectionString, {
- ConnectionInfo? connectionInfo,
Create Supabase adapter from connection string.
Supports both pooled and direct connections:
- Pooled:
postgresql://user:pass@host:6543/db?pgbouncer=true - Direct:
postgresql://user:pass@host:5432/db
Implementation
static Future<SupabaseAdapter> fromConnectionString(
String connectionString, {
ConnectionInfo? connectionInfo,
}) async {
final uri = Uri.parse(connectionString);
final connection = await pg.Connection.open(
pg.Endpoint(
host: uri.host,
port: uri.port,
database:
uri.pathSegments.isNotEmpty ? uri.pathSegments.first : 'postgres',
username: uri.userInfo.split(':').first,
password: uri.userInfo.split(':').last,
),
settings: const pg.ConnectionSettings(
sslMode: pg.SslMode.require,
),
);
return SupabaseAdapter(connection, connectionInfo: connectionInfo);
}