content
stringlengths
14
222
<s>k":"668"}{"_eq":[{"_media":"size""~k":"66b"}"xs"]"~k":"66a"}]"~k":"667"}"layout":{"contentJustify":"center""~k":"66c"}"blockId":"footer_logo_box_sm""areas":{"content":{"blocks":[{"id":"block:<s>
<s>tutorial-requests-sql:footer_logo:1""type":"Html""properties":{"html":"\u003cp style=\"text-align: center;\"\u003e\u003ca href=\"https://lowdefy.com\" ref=\"noopener\"\u003e\u003cimg src=\"/logo-lig<s>
<s>ht-theme.png\" width=\"126px\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp style=\"text-align: center; font-size: 0.85rem;\" \u003eBuild internal tools with YAML.\u003c/p\u003e\n\u003cp style=\"text-<s>
<s>align: center;\"\u003e\u003ca href=\"mailto:hello@lowdefy.com\"\u003ehello@lowdefy.com\u003c/a\u003e\u003c/p\u003e\n""~k":"66g"}"blockId":"footer_logo""~k":"66f"}{"id":"block:tutorial-requests-sql<s>
<s>:community_links:1""type":"Box""layout":{"contentJustify":"space-around""size":200"~k":"66i"}"blockId":"community_links""areas":{"content":{"blocks":[{"id":"block:tutorial-requests-sql:lowdefy_t<s>
<s>witter:1""type":"Icon""layout":{"size":"auto""~k":"66m"}"properties":{"name":"AiOutlineTwitter""size":24"~k":"66n"}"events":{"onClick":{"try":[{"id":"link_twitter""type":"Link""params":{"url"<s>
<s>:"https://twitter.com/lowdefy""newTab":true"~k":"66r"}"~k":"66q"}]"catch":[]"~k":"66p"}"~k":"66o"}"blockId":"lowdefy_twitter""~k":"66l"}{"id":"block:tutorial-requests-sql:lowdefy_community:1"<s>
<s>"type":"Icon""layout":{"size":"auto""~k":"66t"}"properties":{"name":"AiOutlineComment""size":24"~k":"66u"}"events":{"onClick":{"try":[{"id":"link_community""type":"Link""params":{"url":"https<s>
<s>://github.com/lowdefy/lowdefy/discussions""newTab":true"~k":"66y"}"~k":"66x"}]"catch":[]"~k":"66w"}"~k":"66v"}"blockId":"lowdefy_community""~k":"66s"}{"id":"block:tutorial-requests-sql:lowdef<s>
<s>y_github:1""type":"Icon""layout":{"size":"auto""~k":"670"}"properties":{"name":"AiOutlineGithub""size":24"~k":"671"}"events":{"onClick":{"try":[{"id":"link_github""type":"Link""params":{"url"<s>
<s>:"https://github.com/lowdefy/lowdefy""newTab":true"~k":"675"}"~k":"674"}]"catch":[]"~k":"673"}"~k":"672"}"blockId":"lowdefy_github""~k":"66z"}{"id":"block:tutorial-requests-sql:lowdefy_youtub<s>
<s>e:1""type":"Icon""layout":{"size":"auto""~k":"677"}"properties":{"name":"AiOutlineYoutube""size":24"~k":"678"}"events":{"onClick":{"try":[{"id":"link_youtube""type":"Link""params":{"url":"htt<s>
<s>ps://www.youtube.com/channel/UCQLUr15MfP_9yGSO5dmf9wg""newTab":true"~k":"67c"}"~k":"67b"}]"catch":[]"~k":"67a"}"~k":"679"}"blockId":"lowdefy_youtube""~k":"676"}]"~k":"66k"}"~k":"66j"}"~k":"<s>
<s>66h"}]"~k":"66e"}"~k":"66d"}"~k":"666"}{"id":"block:tutorial-requests-sql:lowdefy_cc_box:0""type":"Box""blockId":"lowdefy_cc_box""areas":{"content":{"blocks":[{"id":"block:tutorial-requests-sql<s>
<s>:lowdefy_cc:0""type":"Html""properties":{"html":"\u003cdiv style=\"text-align: center; font-size: 12px; margin-top: 42px;\"\u003e© 2023 Lowdefy Inc. - Give. Easy. Value.\u003c/div\u003e\n""~k":"67<s>
<s>h"}"blockId":"lowdefy_cc""~k":"67g"}]"~k":"67f"}"~k":"67e"}"~k":"67d"}]"~k":"62w"}"~k":"62v"}"~k":"62s"}]"~k":"5yu"}"content":{"justify":"center""blocks":[{"id":"block:tutorial-requests-sql<s>
<s>:max_width:0""type":"Box""layout":{"flex":"0 1 800px""~k":"67k"}"blockId":"max_width""areas":{"content":{"blocks":[{"id":"block:tutorial-requests-sql:page_title:0""type":"Title""properties":{"c<s>
<s>ontent":"6. Saving data to SQL""~k":"67o"}"blockId":"page_title""~k":"67n"}{"id":"block:tutorial-requests-sql:content:0""type":"Box""layout":{"contentGutter":16"~k":"67q"}"blockId":"content""<s>
<s>areas":{"content":{"blocks":[{"id":"block:tutorial-requests-sql:body_sqlite:0""type":"MarkdownWithCode""properties":{"content":"If you have been following along you can continue with your current c<s>
<s>onfig. Else you can find the config from the previous section [here](https://github.com/lowdefy/lowdefy-example-tutorial/tree/main/05-requests-api).\n\nWe will now add a `SQLite` [connection and requ<s>
est](/connections-and-requests) to our app to save user tickets to the SQLite database file.\n\n## Configuring the SQLite Connection and Request\n\nWe will be saving the data from our form in a SQLite
<s> database using the [`Knex`](/SQLite) connection. To do this we will first need to set up an SQLite database as described in the following steps:\n\n#### 6.1. Setting up the SQLite database\n\nWe wi<s>
<s>ll make use of an SQLite database with a table called `tickets` that has the following columns:\n\n- ticket_title\n- ticket_type\n- ticket_description\n- product\n- purchase_in_last_month\n- created_<s>
<s>date\n""~k":"67u"}"blockId":"body_sqlite""~k":"67t"}{"id":"block:tutorial-requests-sql:table_download:0""type":"DangerousMarkdown""properties":{"content":"The database used in this tutorial can <s>
<s>be downloaded \u003ca href=\"/tutorial/tutorial_db.sqlite\" download\u003ehere\u003c/a\u003e.\n""~k":"67w"}"blockId":"table_download""~k":"67v"}{"id":"block:tutorial-requests-sql:body_sqlite_steps<s>
<s>:0""type":"MarkdownWithCode""properties":{"content":{"_nunjucks":{"on":{"version":"4.0.0-rc.10""~k":"681"}"template":"Alternatively install [SQLite](https://www.sqlite.org/) on your computer and <s>
<s>use the following to create the needed table:\n\n```\nCREATE TABLE tickets (\n ticket_title varchar(100)\n ticket_type varchar(50)\n ticket_description varchar(200)\n product varchar(100)\n p<s>
<s>urchase_in_last_month real\n created_date real\n);\n```\n\n#### 6.2. Setting app environment variables\n\nCreate a file called `.env` in your project directory with the following:\n\n##### `.env`\n`<s>
<s>``\nLOWDEFY_SECRET_FILENAME= __ABSOLUTE_PATH_TO_SQLITE_DB_FILE__\n```\n\n#### 5.2.3. Setting the connection environment variable secrets\n\nIn your `lowdefy.yaml` file add the following:\n\n##### `lo<s>
wdefy.yaml`\n\n```yaml\nname: lowdefy-project-template\nversion: {{ version }}\n\nconnections:\n # ...\n################ -------- Copy from here -------- ################\n - id: knex\n type:
Knex\n properties:\n client: sqlite\n connection:\n filename:\n _secret: SQLITE_FILENAME\n################ ------- Copy to here ----------- ################\n\n
<s>menus:\n # ...\n```\n\n#### 6.3. Creating a save data request\n\nIn your `new-ticket.yaml` file add the following request:\n\n##### `pages/new-ticket.yaml`\n\n```yaml\nid: new-ticket\ntype: PageHead<s>
erMenu\nrequests:\n # ...\n################ -------- Copy from here -------- ################\n - id: save_new_ticket\n type: KnexRaw\n connectionId: knex\n payload:\n _state: true\n
<s> properties:\n query: |\n INSERT INTO tickets (\n ticket_title\n ticket_type\n ticket_description\n product\n purchase_in_last_month\n creat<s>
<s>ed_date)\n VALUES(\n :ticket_title\n :ticket_type\n :ticket_description\n :product\n :purchase_in_last_month\n :created_date)\n parameters:\n<s>
ticket_title:\n _payload: ticket_title\n ticket_type:\n _payload: ticket_type\n ticket_description:\n _payload: ticket_description\n product:\n
_payload: product\n purchase_in_last_month:\n _payload: purchase_in_last_month\n created_date:\n _date: now\n################ ------- Copy to here -----------
################\n\nproperties:\n title: New ticket # The title in the browser tab.\nlayout:\n contentJustify: center # Center the contents of the page\nblocks:\n # ...\n```\n\n#### 6.4. Triggering
<s> the save data request\n\nIn your `new-ticket.yaml` file add the following action to the submit button:\n\n##### `pages/new-ticket.yaml`\n\n```yaml\nid: new-ticket\n# ...\nblocks:\n - id: content_ca<s>
rd\n # ...\n blocks:\n - id: page_heading\n # ...\n # ...\n # ...\n - id: submit_button\n type: Button\n #...\n events:\n onClick:\n
- id: validate\n type: Validate\n ################ -------- Copy from here -------- ################\n - id: save_data # Make a request to the SQLite data
base\n type: Request\n params: save_data\n - id: reset # Reset the form once data has been submitted\n type: Reset\n ################ -----
<s>-- Copy to here ----------- ################\n```\n\nIf you click the submit button your form data should be added into the tickets table.\n\n### What happened\n\nWe set up the table and column names<s>
<s> we will be using in our SQLite database. We need to do this to use the `SQLite` connection.\n\nWe defined the `Knex` connection with the SQLite client.\n\nWe also defined a `KnexRaw` request to sav<s>
<s>e the data to our SQLite database and called that request when clicking the submit button. This was done by making use of the `onCLick` event on the button to execute the [`Request`](/Request) action<s>
to make the API call.\n\n\u003e You can find the final configuration files for this section [here](https://github.com/lowdefy/lowdefy-example-tutorial/tree/main/06-requests-sql).\n\n### Up next\n\nNe
<s>xt we will add a new page to display all open tickets an a table.\n""~k":"680"}"~k":"67z"}"~k":"67y"}"blockId":"body_sqlite_steps""~k":"67x"}{"id":"block:tutorial-requests-sql:nav_buttons:0""t<s>
<s>ype":"Box""style":{"marginTop":"40px""marginBottom":"80px""~k":"683"}"layout":{"contentGutter":16"~k":"684"}"blockId":"nav_buttons""areas":{"content":{"blocks":[{"id":"block:tutorial-requests-s<s>
<s>ql:previous_button:0""type":"Button""layout":{"span":12"~k":"688"}"properties":{"block":true"hideActionLoading":true"icon":"AiOutlineArrowLeft""size":"large""title":"API / HTTP Requests""type<s>
<s>":"default""~k":"689"}"events":{"onClick":{"try":[{"id":"link_back""type":"Link""params":{"pageId":"tutorial-requests-api""~k":"68d"}"~k":"68c"}{"id":"scroll_to_top""type":"ScrollTo""params":<s>
<s>{"top":0"~k":"68f"}"~k":"68e"}]"catch":[]"~k":"68b"}"~k":"68a"}"blockId":"previous_button""~k":"687"}{"id":"block:tutorial-requests-sql:next_button:0""type":"Button""layout":{"span":12"~k":<s>
<s>"68h"}"properties":{"block":true"hideActionLoading":true"icon":"AiOutlineArrowRight""size":"large""title":"Display data""type":"default""~k":"68i"}"events":{"onClick":{"try":[{"id":"link_forwa<s>
<s>rd""type":"Link""params":{"pageId":"tutorial-display-data-page""~k":"68m"}"~k":"68l"}{"id":"scroll_to_top""type":"ScrollTo""params":{"top":0"~k":"68o"}"~k":"68n"}]"catch":[]"~k":"68k"}"~k"<s>
<s>:"68j"}"blockId":"next_button""~k":"68g"}]"~k":"686"}"~k":"685"}"~k":"682"}]"~k":"67s"}"~k":"67r"}"~k":"67p"}]"~k":"67m"}"~k":"67l"}"~k":"67j"}]"~k":"67i"}"~k":"5xc"}"blockId":"tutorial-<s>
<s>requests-sql_page""~k":"5wx"}]"~k":"5wu"}"~k":"5wt"}"requests":[{"id":"request:tutorial-requests-sql:insert_feedback""payload":{"session_id":{"_global":"session_id""~k":"68r"}"page_id":{"_locat<s>
<s>ion":"pageId""~k":"68s"}"url_query":{"_url_query":true"~k":"68t"}"url":{"_location":"href""~k":"68u"}"feedback":{"_state":"feedback""~k":"68v"}"~k":"68q"}"requestId":"insert_feedback""pageId<s>
<s>":"tutorial-requests-sql""~k":"68p"}{"id":"request:tutorial-requests-sql:discord_message_feedback""payload":{"message":{"_nunjucks":{"template":"\nDocs feedback: {{ feedback.score }} - {{ feedback.<s>
<s>text }}\n""on":{"feedback":{"_state":"feedback""~k":"69d"}"~k":"69c"}"~k":"69b"}"~k":"69a"}"~k":"699"}"requestId":"discord_message_feedback""pageId":"tutorial-requests-sql""~k":"698"}{"id":"<s>
<s>request:tutorial-requests-sql:insert_newsletter""payload":{"session_id":{"_global":"session_id""~k":"69k"}"email":{"_state":"email""~k":"69l"}"page_id":{"_location":"pageId""~k":"69m"}"url_quer<s>
<s>y":{"_url_query":true"~k":"69n"}"url":{"_location":"href""~k":"69o"}"~k":"69j"}"requestId":"insert_newsletter""pageId":"tutorial-requests-sql""~k":"69i"}{"id":"request:tutorial-requests-sql:di<s>
<s>scord_message_newsletter""payload":{"message":"New newsletter subscription from docs""~k":"6a0"}"requestId":"discord_message_newsletter""pageId":"tutorial-requests-sql""~k":"69z"}]"operators":[]<s>
<s>"~k":"5wh"}"rootConfig":{"home":{"configured":false"pageId":"introduction"}"lowdefyGlobal":{"all_icons":["AiFillAlert""AiFillApi""AiFillBell""AiFillCamera""AiFillCheckCircle""AiOutlineCloseCi<s>
<s>rcle""AiOutlineException""AiOutlineExclamation""AiOutlineExperiment""AiOutlineForm""AiOutlineHome"]"settings_input_layout":{"span":23"sm":{"span":23"~k":"327"}"~k":"326"}"~k":"325"}"menus":<s>
<s>[{"id":"menu:default""links":[{"id":"menuitem:default:introduction""type":"MenuLink""pageId":"introduction""properties":{"title":"Introduction""icon":"AiOutlineCoffee""~k":"32l"}"auth":{"public<s>
<s>":true"~k":"3v4"}"menuItemId":"introduction""~k":"32k"}{"id":"menuitem:default:tutorial""type":"MenuGroup""properties":{"title":"Tutorial""icon":"AiOutlineRocket""~k":"32o"}"links":[{"id":"me<s>
<s>nuitem:default:tutorial-start""type":"MenuLink""pageId":"tutorial-start""properties":{"title":"Getting started""~k":"32q"}"auth":{"public":true"~k":"4au"}"menuItemId":"tutorial-start""~k":"32p<s>
<s>"}{"id":"menuitem:default:tutorial-create-page""type":"MenuLink""pageId":"tutorial-create-page""properties":{"title":"Creating a page""~k":"32t"}"auth":{"public":true"~k":"4p1"}"menuItemId":"t<s>
<s>utorial-create-page""~k":"32s"}{"id":"menuitem:default:tutorial-add-blocks""type":"MenuLink""pageId":"tutorial-add-blocks""properties":{"title":"Adding blocks""~k":"32w"}"auth":{"public":true"<s>
<s>~k":"539"}"menuItemId":"tutorial-add-blocks""~k":"32v"}{"id":"menuitem:default:tutorial-actions-operators""type":"MenuLink""pageId":"tutorial-actions-operators""properties":{"title":"Interactive<s>
<s> pages""~k":"32z"}"auth":{"public":true"~k":"5iw"}"menuItemId":"tutorial-actions-operators""~k":"32y"}{"id":"menuitem:default:tutorial-requests-api""type":"MenuLink""pageId":"tutorial-requests<s>
<s>-api""properties":{"title":"API / HTTP requests""~k":"332"}"auth":{"public":true"~k":"5wg"}"menuItemId":"tutorial-requests-api""~k":"331"}{"id":"menuitem:default:tutorial-requests-sql""type":"<s>
<s>MenuLink""pageId":"tutorial-requests-sql""properties":{"title":"Saving data""~k":"335"}"auth":{"public":true"~k":"6a4"}"menuItemId":"tutorial-requests-sql""~k":"334"}{"id":"menuitem:default:tu<s>
<s>torial-display-data-page""type":"MenuLink""pageId":"tutorial-display-data-page""properties":{"title":"Display data""~k":"338"}"auth":{"public":true"~k":"6nl"}"menuItemId":"tutorial-display-data<s>
<s>-page""~k":"337"}{"id":"menuitem:default:tutorial-next-steps""type":"MenuLink""pageId":"tutorial-next-steps""properties":{"title":"Next steps""~k":"33b"}"auth":{"public":true"~k":"712"}"menuI<s>
<s>temId":"tutorial-next-steps""~k":"33a"}]"auth":{"public":true"~k":"33d"}"menuItemId":"tutorial""~k":"32n"}{"id":"menuitem:default:concepts""type":"MenuGroup""properties":{"title":"Concepts""i<s>
<s>con":"AiOutlineBulb""~k":"33f"}"links":[{"id":"menuitem:default:overview""type":"MenuLink""pageId":"overview""properties":{"title":"Overview""~k":"33h"}"auth":{"public":true"~k":"7ej"}"menuIt<s>
<s>emId":"overview""~k":"33g"}{"id":"menuitem:default:lowdefy-schema""type":"MenuLink""pageId":"lowdefy-schema""properties":{"title":"Lowdefy App Schema""~k":"33k"}"auth":{"public":true"~k":"7sh"<s>
<s>}"menuItemId":"lowdefy-schema""~k":"33j"}{"id":"menuitem:default:blocks""type":"MenuLink""pageId":"blocks""properties":{"title":"Blocks""~k":"33n"}"auth":{"public":true"~k":"9am"}"menuItemId<s>
<s>":"blocks""~k":"33m"}{"id":"menuitem:default:events-and-actions""type":"MenuLink""pageId":"events-and-actions""properties":{"title":"Events and Actions""~k":"33q"}"auth":{"public":true"~k":"as<s>
<s>6"}"menuItemId":"events-and-actions""~k":"33p"}{"id":"menuitem:default:operators""type":"MenuLink""pageId":"operators""properties":{"title":"Operators""~k":"33t"}"auth":{"public":true"~k":"b5<s>
<s>n"}"menuItemId":"operators""~k":"33s"}{"id":"menuitem:default:connections-and-requests""type":"MenuLink""pageId":"connections-and-requests""properties":{"title":"Connections and Requests""~k":"<s>
<s>33w"}"auth":{"public":true"~k":"aep"}"menuItemId":"connections-and-requests""~k":"33v"}{"id":"menuitem:default:page-and-app-state""type":"MenuLink""pageId":"page-and-app-state""properties":{"t<s>
<s>itle":"Page and App State""~k":"33z"}"auth":{"public":true"~k":"8x1"}"menuItemId":"page-and-app-state""~k":"33y"}{"id":"menuitem:default:references-and-templates""type":"MenuLink""pageId":"ref<s>
<s>erences-and-templates""properties":{"title":"References and Templates""~k":"342"}"auth":{"public":true"~k":"8jh"}"menuItemId":"references-and-templates""~k":"341"}{"id":"menuitem:default:menus"<s>
<s>"type":"MenuLink""pageId":"menus""properties":{"title":"Menus""~k":"345"}"auth":{"public":true"~k":"860"}"menuItemId":"menus""~k":"344"}{"id":"menuitem:default:layout""type":"MenuLink""page<s>
<s>Id":"layout-overview""properties":{"title":"Layout""~k":"348"}"auth":{"public":true"~k":"a0u"}"menuItemId":"layout""~k":"347"}{"id":"menuitem:default:secrets""type":"MenuLink""pageId":"secret<s>
<s>s""properties":{"title":"Secrets""~k":"34b"}"auth":{"public":true"~k":"bj6"}"menuItemId":"secrets""~k":"34a"}{"id":"menuitem:default:lists""type":"MenuLink""pageId":"lists""properties":{"tit<s>
<s>le":"Lists""~k":"34e"}"auth":{"public":true"~k":"bwn"}"menuItemId":"lists""~k":"34d"}{"id":"menuitem:default:hosting-files""type":"MenuLink""pageId":"hosting-files""properties":{"title":"Host<s>
<s>ing Files""~k":"34h"}"auth":{"public":true"~k":"ca4"}"menuItemId":"hosting-files""~k":"34g"}{"id":"menuitem:default:custom-styling""type":"MenuLink""pageId":"custom-styling""properties":{"tit<s>
<s>le":"Custom Styling""~k":"34k"}"auth":{"public":true"~k":"d17"}"menuItemId":"custom-styling""~k":"34j"}{"id":"menuitem:default:custom-html""type":"MenuLink""pageId":"custom-html""properties":<s>
<s>{"title":"Custom HTML""~k":"34n"}"auth":{"public":true"~k":"cnq"}"menuItemId":"custom-html""~k":"34m"}{"id":"menuitem:default:cli""type":"MenuLink""pageId":"cli""properties":{"title":"The CLI<s>
<s>""~k":"34q"}"auth":{"public":true"~k":"de1"}"menuItemId":"cli""~k":"34p"}]"auth":{"public":true"~k":"34s"}"menuItemId":"concepts""~k":"33e"}{"id":"menuitem:default:deployment""type":"MenuGr<s>
<s>oup""properties":{"title":"Deployment""icon":"AiOutlineCloudUpload""~k":"34u"}"links":[{"id":"menuitem:default:docker""type":"MenuLink""pageId":"docker""properties":{"title":"Docker""~k":"34w"<s>
<s>}"auth":{"public":true"~k":"dqv"}"menuItemId":"docker""~k":"34v"}{"id":"menuitem:default:node-server""type":"MenuLink""pageId":"node-server""properties":{"title":"Node.js""~k":"34z"}"auth":{<s>
<s>"public":true"~k":"e3p"}"menuItemId":"node-server""~k":"34y"}{"id":"menuitem:default:vercel""type":"MenuLink""pageId":"vercel""properties":{"title":"Vercel""~k":"352"}"auth":{"public":true"~<s>
<s>k":"egj"}"menuItemId":"vercel""~k":"351"}]"auth":{"public":true"~k":"354"}"menuItemId":"deployment""~k":"34t"}{"id":"menuitem:default:plugins_group""type":"MenuGroup""properties":{"title":"Pl<s>
<s>ugins""icon":"AiOutlineCode""~k":"356"}"links":[{"id":"menuitem:default:plugins-introduction""type":"MenuLink""pageId":"plugins-introduction""properties":{"title":"Introduction""~k":"358"}"aut<s>
<s>h":{"public":true"~k":"eu0"}"menuItemId":"plugins-introduction""~k":"357"}{"id":"menuitem:default:plugins-dev""type":"MenuLink""pageId":"plugins-dev""properties":{"title":"Developing Plugins""<s>
<s>~k":"35b"}"auth":{"public":true"~k":"f7l"}"menuItemId":"plugins-dev""~k":"35a"}{"id":"menuitem:default:plugins-actions""type":"MenuLink""pageId":"plugins-actions""properties":{"title":"Actions<s>
<s>""~k":"35e"}"auth":{"public":true"~k":"fl2"}"menuItemId":"plugins-actions""~k":"35d"}{"id":"menuitem:default:plugins-connections""type":"MenuLink""pageId":"plugins-connections""properties":{"<s>