Kit Fox
Kit Fox

Reputation: 129

How do i access MySQL with Erlang's Yaws web server

is it possible? if so, how?

I know php and MySQL run together with Apache.

but, how can I get access to the MySQL database using Yaws script?

Upvotes: 1

Views: 537

Answers (1)

Daniel Klöck
Daniel Klöck

Reputation: 21137

Yes, it is possible, here is some example code:

<erl> 

out(A) -> 
    application:start(odbc), 
    ConnString = 
        "Driver={MySQL ODBC 5.1 Driver};" ++ 
        "Server=localhost;Database=test;" ++ 
        "User=root;Password=ace152;" ++ 
        "Option=3;", 
    {ok, Conn} = odbc:connect(ConnString, []), 
    Results = odbc:sql_query(Conn, "SELECT * FROM test_table"), 
    {html,"Something here."}. 

</erl> 

Upvotes: 3

Related Questions