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
+195-1Lines changed: 195 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1013,6 +1013,199 @@ 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
+
#### Configuration
1036
+
1037
+
When configuring these actions, you'll need to provide:
1038
+
1039
+
1. Database app type and auth (e.g., `postgresql` in this example)
1040
+
2. A `sql` prop with the following structure:
1041
+
1042
+
```javascript
1043
+
constconfiguredProps= {
1044
+
postgresql: {
1045
+
authProvisionId:"apn_xxxxxxx""
1046
+
},
1047
+
sql: {
1048
+
auth: {
1049
+
app: "postgresql" // Database type -- must match the app prop name
1050
+
},
1051
+
query: "select * from products limit 1",
1052
+
params: [] // Optional array of parameters for prepared statements
1053
+
}
1054
+
}
1055
+
```
1056
+
1057
+
#### Using prepared statements
1058
+
1059
+
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:
1060
+
1061
+
- **PostgreSQL** uses `$1`, `$2`, `$3`, etc. for numbered parameters
1062
+
- **Snowflake**, **MySQL, Azure SQL, Microsoft SQL Server, and Turso** use `?` for positional parameters
1063
+
1064
+
**PostgreSQL Example:**
1065
+
```javascript
1066
+
const configuredProps = {
1067
+
postgresql: {
1068
+
authProvisionId: process.env.ACCOUNT_ID
1069
+
},
1070
+
sql: {
1071
+
auth: {
1072
+
app: "postgresql"
1073
+
},
1074
+
query: "select * from products where name = $1 and price > $2 limit 1",
1075
+
params: ["foo", 10.99] // Values to replace $1 and $2 placeholders
1076
+
}
1077
+
}
1078
+
```
1079
+
1080
+
**MySQL Example:**
1081
+
```javascript
1082
+
const configuredProps = {
1083
+
mysql: {
1084
+
authProvisionId: process.env.ACCOUNT_ID
1085
+
},
1086
+
sql: {
1087
+
auth: {
1088
+
app: "mysql"
1089
+
},
1090
+
query: "select * from products where name =? and price >? limit 1",
1091
+
params: ["foo", 10.99] // Values to replace the ? placeholders
1092
+
}
1093
+
}
1094
+
```
1095
+
1096
+
<Callout type="info">
1097
+
Using prepared statements helps prevent SQL injection attacks by separating the SQL command structure from the data values being used, and is strongly recommended.
1098
+
</Callout>
1099
+
1100
+
#### Retrieving database schema information
1101
+
1102
+
By retrieving the database schema, developers can:
1103
+
1104
+
- Provide database structure to AI agents for accurate SQL generation
1105
+
- Build native SQL editors with autocomplete for tables and columns
1106
+
- Validate queries against the actual database schema before execution
1107
+
1108
+
You can call `configureComponent` on the `sql` prop to retrieve database schema information:
1109
+
1110
+
```javascript
1111
+
const resp = await pd.configureComponent({
1112
+
externalUserId: externalUserId,
1113
+
propName: "sql",
1114
+
componentId: {
1115
+
key: "postgresql-execute-custom-query",
1116
+
},
1117
+
configuredProps: {
1118
+
postgresql: {
1119
+
authProvisionId: accountId
1120
+
},
1121
+
},
1122
+
});
1123
+
```
1124
+
1125
+
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 +1295,5 @@ The sources UI contains three tabs:
1102
1295
1103
1296
<Callout type="info">
1104
1297
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