Innov-AI
    Documentation | MentDB Weak Server
Read a SQL Database and write a regular text file

  • Method 1:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	-> "TEXT" "";
    	sql parse "session1" "T" (concat "select id, name, quantity from products") {
    
    		concat_var "[TEXT]" [_n_] "," [T_id] "," [T_quantity];
    	
    	};
    
    	sql disconnect "session1";
    
    	file create "data/file.txt" [TEXT];
    
    } {
    
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
  • Method 2:
  • try {
    
    	sql connect "session1" {cm get "demo_cm_mysql";};
    
    	file writer_open "w1" "data/file.txt" false TEXT "utf-8";
    	
    	sql parse "session1" "T" (concat "select id, name, quantity from products") {
    
    		file writer_add_line "w1" (concat [_n_] "," [T_id] "," [T_quantity] "," [T_name]);
    	
    	};
    
    	file writer_close "w1";
    	sql disconnect "session1";
    
    } {
    
    	try {file writer_close "w1";} {} "[err]";
    	try {sql disconnect "session1";} {} "[err]";
    
    } "[err]";
Services     Supporters     Contact     About     Legal notice © 2024