mysqlerlangerlang-otperl

How do I install a driver in Erlang? (Specifically MySQL-otp driver)


From the documentation this driver looks great. I don't know how to install it so that I can use it though. I read somewhere that I should maybe use rebar? I looked at that documentation though and it appears to have the opposite problem. It says how to install it, but not how to use it.


Update

So it looks like after installing rebar, I can add the lines

{deps, [
    {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
                   {tag, "1.3.3"}}}
]}.

to my file rebar.config. I don't know what this does though. Do I have to compile or make this file now? Does rebar.config have to be in the same directory as my project? Right not the path to rebar.config is ~/rebar/rebar.config Is it all correct to place my project so that it is a sibling to rebar in the file hierarchy?


Update

I ran ./rebar get-deps with the rebar folder and got

Pulling mysql from {git,"https://github.com/mysql-otp/mysql-otp",
                        {tag,"1.3.3"}}
Cloning into 'mysql'...
==> mysql (get-deps)

I still don't really know what this means though, and when I try compiling my erlang file I receive the result.

c(erlangFile.erl).
{error,non_existing}

Solution

  • Download your package, in this case

    git clone https://github.com/mysql-otp/mysql-otp.git
    

    Download a tool called rebar

    git clone git://github.com/rebar/rebar.git
    cd rebar
    ./bootstrap
    

    Add the following to rebar/rebar.config

    {deps, [
        {mysql, ".*", {git, "https://github.com/mysql-otp/mysql-otp",
                       {tag, "1.3.3"}}}
    ]}.
    

    Within the rebar/mysql-otp directory run

    ./rebar get-deps
    

    Then within the same directory, run

    ./rebar compile
    

    This will put a bunch of .beam files and .app file into the ebin/ directory

    Next add the ebin/ directory to your path. You can update your $ERL_LIBS environment variable, run an include command within the erlang console like

    1> code:add_pathz("~/rebar/mysql-otp/ebin").
    

    or

    1> code:add_pathz("rebar/mysql-otp/ebin")
    

    And theres a few other ways to add it to your Erlang path.


    Also, make sure mysql is also installed

    Heres a few links with mysql installation instructions that worked for me

    https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7

    No package msyql-server available