1

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}
Sam
  • 1,765
  • 11
  • 82
  • 176

2 Answers2

1

rebar is a build tool for erlang.Please go through https://github.com/rebar/rebar/wiki/Rebar-commands for the commands. After getting dependency, "rebar compile" is required to compile it. For using the beam files, you have to give output beam path using Add Path to Erlang Search Path? these methods. Then you will be able to use it in your code.

Girdhar Sojitra
  • 648
  • 4
  • 14
  • Thank you. I don't think really know what beam files are. The name rings a bell but I'm new enough to Erlang that I don't think I've learned what they are. Would you be able to explain them in this specific context. And is the Erlang path similar to a PythonPath or ShellPath but this one is just for Erlang? Thanks again. – Sam Dec 10 '18 at 07:45
  • you should first go through basics of erlang before going forward.go through this https://learnyousomeerlang.com/content – Girdhar Sojitra Dec 10 '18 at 08:12
  • I'm just going to research beam files, because I've already read through several tutorials like that – Sam Dec 10 '18 at 08:32
  • I don't think I ever use beam files because I always just run `erl` on the command line and then `c(myerlangfile).` Do I have to use them in this case? – Sam Dec 11 '18 at 14:44
1

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

Sam
  • 1,765
  • 11
  • 82
  • 176