Innov-AI
    Documentation | MentDB Weak Server
Manage remote block on a remote SQL table

  • #Connect to the remote MentDB Server;
    tunnel connect "session1" {cm get "demo_cm_mentdb";};
    
    #Connect to the remote SQL Database;
    tunnel execute "session1" (concat 
    	(mql {
    		sql connect "session1" {cm get "demo_cm_mysql";};
    		sql block open "session1" tablename (concat "select * from products");
    	})
    );
    
    #Get the first block (return 1 line by block);
    json load "result_block" (tunnel execute "session1" (concat 
    	(mql {
    		sql block to_json 1
    	})
    ));
    
    while (> (json count "result_block" /data) 0) {
    
    	#JSON return examples;
    	"{\"data\":[{\"title\":\"User Manager\",\"app_id\":\"user_manager\"}],\"columns\":[\"app_id\",\"title\"],\"table\":\"tablename\"}";
    	"{\"data\":[],\"columns\":[\"app_id\",\"title\"],\"table\":\"tablename\"}";
    
    	#Execute actions here...;
    
    	
    	#Get the other blocks (return 1 line by block);
    	json load "result_block" (tunnel execute "session1" (concat 
    		(mql {
    			sql block to_json 1
    		})
    	));
    
    };
    
    #Disonnect to the remote SQL Database;
    tunnel execute "session1" (concat 
    	(mql {
    		sql block close;
    		sql disconnect "session1";
    	})
    );
    
    #Disconnect to the remote MentDB Server;
    tunnel disconnect "session1";
Services     Supporters     Contact     About     Legal notice © 2024