@@ -21,26 +21,40 @@ function getSqlEnvVarName(integrationId: string): string {
2121
2222/**
2323 * Converts integration configuration to the JSON format expected by the SQL execution code.
24+ * The format must match what deepnote_toolkit expects:
25+ * {
26+ * "url": "sqlalchemy_connection_url",
27+ * "params": {},
28+ * "param_style": "qmark" | "format" | etc.
29+ * }
2430 */
2531function convertIntegrationConfigToJson ( config : IntegrationConfig ) : string {
2632 switch ( config . type ) {
27- case IntegrationType . Postgres :
33+ case IntegrationType . Postgres : {
34+ // Build PostgreSQL connection URL
35+ // Format: postgresql://username:password@host :port/database
36+ const encodedUsername = encodeURIComponent ( config . username ) ;
37+ const encodedPassword = encodeURIComponent ( config . password ) ;
38+ const url = `postgresql://${ encodedUsername } :${ encodedPassword } @${ config . host } :${ config . port } /${ config . database } ` ;
39+
2840 return JSON . stringify ( {
29- type : 'postgres' ,
30- host : config . host ,
31- port : config . port ,
32- database : config . database ,
33- username : config . username ,
34- password : config . password ,
35- ssl : config . ssl ?? false
41+ url : url ,
42+ params : config . ssl ? { sslmode : 'require' } : { } ,
43+ param_style : 'format'
3644 } ) ;
45+ }
3746
38- case IntegrationType . BigQuery :
47+ case IntegrationType . BigQuery : {
48+ // BigQuery uses a special URL format
3949 return JSON . stringify ( {
40- type : 'bigquery' ,
41- project_id : config . projectId ,
42- credentials : JSON . parse ( config . credentials ) // Parse the JSON string to an object
50+ url : 'bigquery://?user_supplied_client=true' ,
51+ params : {
52+ project_id : config . projectId ,
53+ credentials : JSON . parse ( config . credentials )
54+ } ,
55+ param_style : 'format'
4356 } ) ;
57+ }
4458
4559 default :
4660 throw new Error ( `Unsupported integration type: ${ ( config as IntegrationConfig ) . type } ` ) ;
0 commit comments