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
{{ message }}
Repository navigation
Commit 3788c61
Browse filesBrowse the repository at this point in the historyBrowse files
from json_each(sqlpage.exec('curl', 'https://jsonplaceholder.typicode.com/users'));
26
+
```
27
+
28
+
#### Notes
29
+
30
+
- This function is disabled by default for security reasons. You can enable it by setting `"allow_exec" : true` in `sqlpage/sqlpage.json`. Enable it only if you trust all the users that can access your SQLPage server files (both locally and on the database).
31
+
- Be careful when using this function, as it can be used to execute arbitrary shell commands on your server. Do not use it with untrusted input.
32
+
- The command is executed in the current working directory of the SQLPage server process.
33
+
- The command is executed with the same user as the SQLPage server process.
34
+
- The environment variables of the SQLPage server process are passed to the command, including potentially sensitive variables such as `DATABASE_URL`.
35
+
- The command is executed asynchronously, but the SQLPage server has to wait for it to finish before sending the result to the client.
36
+
This means that the SQLPage server will not be blocked while the command is running, it will be able to serve other requests, but it will not be able to serve the current request until the command has finished.
37
+
You should generally avoid long running commands.
38
+
- If the program name is NULL, the result will be NULL.
39
+
- If any argument is NULL, it will be passed to the command as an empty string.
40
+
- If the command exits with a non-zero exit code, the function will raise an error.
41
+
- Arbitrary SQL operations are not allowed as sqlpage function arguments. Use `SET` to assign the result of a SQL query to a variable, and then use that variable as an argument to `sqlpage.exec`.
42
+
- When `sqlpage.exec(...)` is a standalone selected column, the command runs once per returned row. Use `SET command_result = sqlpage.exec(...)` first if the command should run only once for the page.
Which will make `$param1` and `$param2` available in the included file.
72
81
[More information about building JSON objects in SQL](/blog.sql?post=JSON%20in%20SQL%3A%20A%20Comprehensive%20Guide).
73
-
'
74
-
);
75
-
INSERT INTO sqlpage_function_parameters (
76
-
"function",
77
-
"index",
78
-
"name",
79
-
"description_md",
80
-
"type"
81
-
)
82
-
VALUES (
83
-
'run_sql',
84
-
1,
85
-
'file',
86
-
'Path to the SQL file to execute, can be absolute, or relative to the web root (the root folder of your website sql files).
87
-
In-database files, from the sqlpage_files(path, contents, last_modified) table are supported.',
88
-
'TEXT'
89
-
),(
90
-
'run_sql',
91
-
2,
92
-
'parameters',
93
-
'Optional JSON object to pass as parameters to the included SQL file. The keys of the object will be available as variables in the included file. By default, the included file will have access to the same variables as the calling file.',
0 commit comments