You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-v2/pages/connect/components.mdx
+170-1Lines changed: 170 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1013,6 +1013,174 @@ curl -X POST https://api.pipedream.com/v1/connect/{project_id}/components/trigge
1013
1013
}
1014
1014
```
1015
1015
1016
+
## Special Prop Types
1017
+
1018
+
### SQL Prop
1019
+
1020
+
The `sql` prop is a specialized prop type used for interacting with SQL databases. It enables developers to build applications that can:
1021
+
1022
+
- Execute custom SQL queries
1023
+
- Introspect database schemas
1024
+
- Support prepared statements
1025
+
1026
+
This prop type is used by these database actions:
1027
+
1028
+
-`postgresql-execute-custom-query`
1029
+
-`snowflake-execute-sql-query`
1030
+
-`mysql-execute-raw-query`
1031
+
-`microsoft_sql_server-execute-raw-query`
1032
+
-`azure_sql-execute-raw-query`
1033
+
-`turso-execute-query`
1034
+
1035
+
<Callouttype="warning">
1036
+
The `sql` prop is only supported in the Pipedream server SDK and REST API, and is not currently supported in `connect-react`.
1037
+
</Callout>
1038
+
1039
+
#### Configuration
1040
+
1041
+
When configuring these actions, you'll need to provide:
1042
+
1043
+
1. Database app type and auth (e.g., `postgresql` in this example)
1044
+
2. A `sql` prop with the following structure:
1045
+
1046
+
```javascript
1047
+
constconfiguredProps= {
1048
+
postgresql: {
1049
+
authProvisionId:"apn_xxxxxxx"
1050
+
},
1051
+
sql: {
1052
+
auth: {
1053
+
app:"postgresql"// Database type -- must match the app prop name
1054
+
},
1055
+
query:"select * from products limit 1",
1056
+
params: [] // Optional array of parameters for prepared statements
1057
+
}
1058
+
}
1059
+
```
1060
+
1061
+
#### Using prepared statements
1062
+
1063
+
You can use prepared statements by including placeholders in your query and providing the parameter values in the `params` array. Different database systems use different placeholder syntax:
1064
+
1065
+
-**PostgreSQL** uses `$1`, `$2`, `$3`, etc. for numbered parameters
1066
+
-**Snowflake**, **MySQL, Azure SQL, Microsoft SQL Server, and Turso** use `?` for positional parameters
query:"select * from products where name = $1 and price > $2 limit 1",
1080
+
params: ["foo", 10.99] // Values to replace $1 and $2 placeholders
1081
+
}
1082
+
}
1083
+
```
1084
+
</Tabs.Tab>
1085
+
<Tabs.Tab>
1086
+
```javascript
1087
+
constconfiguredProps= {
1088
+
mysql: {
1089
+
authProvisionId:"apn_xxxxxxx"
1090
+
},
1091
+
sql: {
1092
+
auth: {
1093
+
app:"mysql"
1094
+
},
1095
+
query:"select * from products where name = ? and price > ? limit 1",
1096
+
params: ["foo", 10.99] // Values to replace the ? placeholders
1097
+
}
1098
+
}
1099
+
```
1100
+
</Tabs.Tab>
1101
+
</Tabs>
1102
+
1103
+
1104
+
<Callouttype="info">
1105
+
Using prepared statements helps prevent SQL injection attacks by separating the SQL command structure from the data values being used, and is strongly recommended.
1106
+
</Callout>
1107
+
1108
+
#### Retrieving database schema information
1109
+
1110
+
By retrieving the database schema, developers can:
1111
+
1112
+
- Provide database structure to AI agents for accurate SQL generation
1113
+
- Build native SQL editors with autocomplete for tables and columns
1114
+
- Validate queries against the actual database schema before execution
1115
+
1116
+
You can call `configureComponent` on the `sql` prop to retrieve database schema information:
1117
+
1118
+
```javascript
1119
+
constresp=awaitpd.configureComponent({
1120
+
externalUserId: externalUserId,
1121
+
propName:"sql",
1122
+
componentId: {
1123
+
key:"postgresql-execute-custom-query",
1124
+
},
1125
+
configuredProps: {
1126
+
postgresql: {
1127
+
authProvisionId: accountId
1128
+
},
1129
+
},
1130
+
});
1131
+
```
1132
+
1133
+
The response includes a `context.dbInfo` object containing detailed schema information for all tables in the database:
### Referencing the app prop in configured props payload
@@ -1102,4 +1270,5 @@ The sources UI contains three tabs:
1102
1270
1103
1271
<Callouttype="info">
1104
1272
This UI view is currently in beta and has some limitations. Some UI elements may appear unpolished, and the configuration tab has limited functionality.
0 commit comments