如何使用 Erlang、Yaws 连接到 mysql 数据库
How to connect to mysql database with Erlang, Yaws
我是 Erlang 和 Yaws 的新手...我正在尝试连接到 mysql 数据库,但我不确定一些事情..
问题。
1。我是否需要额外的库才能使用 Erlang 连接到 mysql 数据库?
2. 如何使用 Erlang 列出可用的数据库驱动程序?
我尝试使用此代码进行连接。
application:start(odbc),
ConnString =
"Driver={MySQL ODBC 5.1 Driver};" ++
"Server=localhost;Database=db;" ++
"User=root;Password=2eklmss;" ++
"Option=3;",
{ok, Conn} = odbc:connect(ConnString, []),
Results = odbc:sql_query(Conn, "SELECT * FROM db"),
{html,"Something here."}.
{我不确定这一行
"Driver={MySQL ODBC 5.1 Driver};" ++
这就是我问第二个问题的原因}
失败并出现以下错误:
ERROR erlang code threw an uncaught exception:
File: /Users/username/Terminal/WebServerA/var/yaws/www/index.yaws:3
Class: error
Exception: undef
Req: {http_request,'GET',{abs_path,"/"},{1,1}}
Stack: [{odbc,connect,
["Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db;User=root;Password= 2eklmss;Option=3;",
[]],
[]},
{m22,out,1,
[{file,"/Users/username/.yaws/yaws/default/m22.erl"},
{line,19}]},
{yaws_server,deliver_dyn_part,8,
[{file,"yaws_server.erl"},{line,2851}]},
{yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1255}]},
{yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1078}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]
我删除了所有代码,只留下这一行。
out(A) ->
application:start(odbc).
发生了以下错误:
yaws code at /Users/username/Terminal/WebServerA/var/yaws/www/index.yaws:3 crashed or ret bad val:{error,
{"no such file or directory",
"odbc.app"}}
Req: {http_request,'GET',{abs_path,"/"},{1,1}}
我是 Erlang 和 Yaws 的新手...我正在尝试连接到 mysql 数据库,但我不确定一些事情..
问题。
1。我是否需要额外的库才能使用 Erlang 连接到 mysql 数据库?
2. 如何使用 Erlang 列出可用的数据库驱动程序?
我尝试使用此代码进行连接。
application:start(odbc),
ConnString =
"Driver={MySQL ODBC 5.1 Driver};" ++
"Server=localhost;Database=db;" ++
"User=root;Password=2eklmss;" ++
"Option=3;",
{ok, Conn} = odbc:connect(ConnString, []),
Results = odbc:sql_query(Conn, "SELECT * FROM db"),
{html,"Something here."}.
{我不确定这一行
"Driver={MySQL ODBC 5.1 Driver};" ++
这就是我问第二个问题的原因}
失败并出现以下错误:
ERROR erlang code threw an uncaught exception:
File: /Users/username/Terminal/WebServerA/var/yaws/www/index.yaws:3
Class: error
Exception: undef
Req: {http_request,'GET',{abs_path,"/"},{1,1}}
Stack: [{odbc,connect,
["Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db;User=root;Password= 2eklmss;Option=3;",
[]],
[]},
{m22,out,1,
[{file,"/Users/username/.yaws/yaws/default/m22.erl"},
{line,19}]},
{yaws_server,deliver_dyn_part,8,
[{file,"yaws_server.erl"},{line,2851}]},
{yaws_server,aloop,4,[{file,"yaws_server.erl"},{line,1255}]},
{yaws_server,acceptor0,2,[{file,"yaws_server.erl"},{line,1078}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]
我删除了所有代码,只留下这一行。
out(A) ->
application:start(odbc).
发生了以下错误:
yaws code at /Users/username/Terminal/WebServerA/var/yaws/www/index.yaws:3 crashed or ret bad val:{error,
{"no such file or directory",
"odbc.app"}}
Req: {http_request,'GET',{abs_path,"/"},{1,1}}