c:cd("/home/alexei/eclipse/data/workspace-CPP/erl.mysql.client/ebin"). code:add_path("/home/alexei/eclipse/data/workspace-CPP/erl.mysql.client/deps/rsrc_pool/ebin"). my:start_client(). rr(".././include/my.hrl"). DS_def = #datasource{host = "localhost", port = 3306, database = "", user = "root", password = "root"}. my:new_datasource(data_source, DS_def). Cntn = datasource:get_connection(data_source). connection:connection_record(Cntn). connection:execute_query(Cntn, "CREATE DATABASE IF NOT EXISTS testDB"). connection:execute_query(Cntn, "CREATE TABLE testDB.sample_table (id bigint(20) NOT NULL AUTO_INCREMENT, name varchar(45) DEFAULT NULL, age int(10) DEFAULT 21, longtext_col longtext, PRIMARY KEY (id)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8"). connection:execute_query(Cntn, "INSERT INTO testDB.sample_table(name) VALUES ('Alex'), ('John')"). connection:execute_query(Cntn, "SELECT * FROM testDB.sample_table"). {_, Rows} = connection:execute_query(Cntn, "SELECT * FROM testDB.sample_table"). Rows. [_, Row] = Rows. Row. [_, Name, Age, _] = Row. Name. Response = connection:execute_query(Cntn, "SELECT * FROM testDB.sample_table"). Cursor = cursor:new(Response). cursor:next(Cursor). cursor:set(Cursor, 1). Name1 = cursor:get(Cursor, "name"). Age1 = cursor:get(Cursor, "age"). cursor:next(Cursor). Name2 = cursor:get(Cursor, 2). cursor:foreach(Cursor, "name"). H = connection:get_prepared_statement_handle(Cntn, "SELECT * FROM testDB.sample_table WHERE id = ?"). {_,[R|_]} = connection:execute_statement(Cntn, H, [8], [1]). R. H1 = connection:get_prepared_statement_handle(Cntn, "SELECT * FROM testDB.sample_table WHERE id < ?"). LONGLONG = 8. CURSOR_TYPE_READ_ONLY = 1. {M,_} = connection:execute_statement(Cntn, H1, [LONGLONG], [3], CURSOR_TYPE_READ_ONLY, true). {_,R1} = connection:fetch_statement(Cntn, H1, M, 2). F = fun (C) -> connection:execute_query(C, "UPDATE testDB.sample_table SET age = age + 1 WHERE id = 1") end. Result = case connection:transaction(Cntn, F) of #mysql_error{} -> io:format("Transaction is failed and rollbacked ~n"), failed; R2 -> R2 end. Handle = connection:get_prepared_statement_handle(Cntn, "UPDATE testDB.sample_table SET longtext_col= ? WHERE id = ?"). connection:send_statement_long_parameter(Cntn, Handle, 0, <<16#AA:8000000>>). LONG_BLOB = 251. connection:execute_statement(Cntn, Handle, [LONG_BLOB, LONGLONG], [null, 1]). connection:execute_query(Cntn, "SELECT longtext_col FROM testDB.sample_table WHERE id = 1"). datasource:return_connection(data_source, Cntn). DS_def_compr = #datasource{host = "localhost", port = 3306, database = "testDB", user = "root", password = "root", flags = #client_options{compress=1}}. my:new_datasource(datasource_compr, DS_def_compr). Connection = datasource:get_connection(datasource_compr). connection:execute_query(Connection, "DROP DATABASE IF EXISTS testDB").