Skip to content

Latest commit

 

History

History
 
 

samples

Emysql Samples

Sample programs are in ./samples.

Running Samples

1. Build Emysql

Build emysql.app, using make:

$ cd Emysql
$ make

2. Make a Sample Database

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';

3. Running the Samples

$ 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