Skip to content

custom sql queries #518

Answered by lovasoa
isriam asked this question in Q&A
Jul 31, 2024 · 4 comments · 1 reply
Discussion options

You must be logged in to vote

SQLPage itself currently doesn't have an option to run arbitrary sql defined by the end user. I am reluctant to adding something like that, since this feature has a great potential for misuse and would probably most of the time result in vulnerabilities in the application.

If you really want to, you can save the user query in a file and run with run_sql. But be very careful and please think twice about the security implications if you do that.

query.sql

set Query = COALESCE($Query, 'SELECT * from todo')

select 'form' as component;
select 'Query' as name, $Query as value;

set tmp_sql_file = sqlpage.exec('./query_write_tmp_sql.sh', $Query);

select 'table' as component, true as search, true 

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lovasoa
Comment options

Answer selected by isriam
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
sql Topic related to SQL, not specific to SQLPage form Building forms in SQL; questions about the form component
2 participants