Sample programs are in ./samples.
- a_hello - Hello World
- b_raw - Hello World, raw output
- c_rows_as_records - Using Erlang records to access result rows
- d_prepared_statement - Using prepared statements
- e_stored_procedure - Using stored procedures
- f_load_from_file - Fast loading from file
Build emysql.app, using make:
$ cd Emysql
$ make
For use in the above sample (and all of those below, too), create a local mysql database. You should have a mysql server installed and running:
$ mysql [-u<user> -p]
mysql> create database hello_database;
mysql> use hello_database;
mysql> create table hello_table (hello_text char(20));
mysql> grant all privileges on hello_database.* to hello_username@localhost identified by 'hello_password';
mysql> grant file on *.* to hello_username@localhost identified by 'hello_password';
$ cd samples
$ ./a_hello
$ ./b_raw
$ ./c_rows_as_records
$ ./d_prepared_statement
$ ./e_stored_procedure
$ ./e_load_from_file
or make emysql.app and the database, as explained above, and start a_hello etc. manually along these lines:
$ make
$ cd samples
$ erlc a_hello.erl
$ erl -pa ../ebin -s a_hello run -s init stop -noshell