try { sql connect "session1" {cm get "demo_cm_mysql";}; -> "[CSV]" "A;B;C"; sql parse "session1" "T" (concat "select id, name, quantity from products") { concat_var "[CSV]" [_n_]; concat_var "[CSV]" (string csv_value [T_id] ";" "'") ";"; concat_var "[CSV]" (string csv_value [T_name] ";" "'") ";"; concat_var "[CSV]" (string csv_value [T_quantity] ";" "'"); }; file create "data/file.csv" [CSV]; sql disconnect "session1"; } { try {sql disconnect "session1";} {} "[err]"; } "[err]";
try { sql connect "session1" {cm get "demo_cm_mysql";}; file writer_open "w1" "data/file.csv" false TEXT "utf-8"; file writer_add_line "w1" "A;B;C"; sql parse "session1" "T" (concat "select id, name, quantity from products") { -> "[CSV]" ""; concat_var "[CSV]" [_n_]; concat_var "[CSV]" (string csv_value [T_id] ";" "'") ";"; concat_var "[CSV]" (string csv_value [T_name] ";" "'") ";"; concat_var "[CSV]" (string csv_value [T_quantity] ";" "'"); file writer_add_line "w1" [CSV]; file writer_flush "w1"; }; file writer_close "w1"; sql disconnect "session1"; } { try {file writer_close "w1";} {} "[err]"; try {sql disconnect "session1";} {} "[err]"; } "[err]";