简体   繁体   中英

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?

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM