Erlang mysql example

后端 未结 3 1763
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 13:34

Just wondering if anyone could give a working example of using the erlang-mysql module (http://code.google.com/p/erlang-mysql-driver/).

I am new to erlang and I am tryin

相关标签:
3条回答
  • 2021-02-06 13:46

    After trying to use the ODBC module that comes with Erlang/OTP, and running into problems, I recommend the mysql/otp driver. I replaced ODBC with it in just a few hrs and it works fine.

    They have good documentation so I will not add examples here.

    0 讨论(0)
  • 2021-02-06 13:58

    This is described in the source code of mysql.erl:

    Your result will be {data, MySQLRes}.

    FieldInfo = mysql:get_result_field_info(MysqlRes), where FieldInfo is a list of {Table, Field, Length, Name} tuples.

    AllRows = mysql:get_result_rows(MysqlRes), where AllRows is a list of lists, each representing a row.

    0 讨论(0)
  • 2021-02-06 14:06

    you should check the count of rows, then execute:

    eg: RowLen = erlang:length(Row), if RowLen > 0 -> {success}; true -> {failed, "Row is null"} end.

    0 讨论(0)
提交回复
热议问题