-
|
I had my application dashboard all in one SQL file. It started by creating two temporary tables (sqlite3) and then various queries to build components. Recently, I refactored it to have multiple files accessed by dynamic component with sqlpage_runsql(). One of the components is a card with two embedded charts - each pointing to its own SQL file using sqlpage.link(). Only for these, often I get error stating temporary table is not created. When I refresh, often times it comes up. Entry point creates a dynamic component running this sql. That includes two embeds which are single sql queries each. I am guessing sqlpage.link() actually creates a new session and that is why temporary tables are not there. On reload, often I get data for previous query. My goal is two simply have two charts side by side. If I can do that with some component using sqlpage.runsql(), then that is great. Otherwise, I will've to write a custom component - wanted to see if any simpler fixes are available. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
The temporary tables you create in Temporary tables are the wrong thing to use if you want to persist data across requests. Use a normal table or url parameters to pass state for anything that has to be persisted. |
Beta Was this translation helpful? Give feedback.
The temporary tables you create in
r_add_temp_tables.sql(viarun_sqlfromindex.sql) live only for the duration of that single database connection. SQLPage may decide to reuse an old connection for a new request or not. Theembedlinks inr_net_chart_by_category.sqlare not server-side includes, they are URLs that the browser fetches as separate HTTP requests after the page loads. Each of those fetches potentially gets its own database connection from the pool, which has no access to the temp tables created on the original request's connection, sor_net_chart_by_category_treemap.sqlandr_net_chart_by_category_time.sqlfail with "no such table". On refresh it sometimes works because the …