Skip to content
@deprecated Pooled ODBC for Erlang
Erlang
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
.gitignore
LICENSE
README.markdown
rebar.config

README.markdown

PLEASE NOTE THIS PROJECT HAS BEEN MOVED! PLEASE USE https://github.com/pannonia-technologies/podbc!

Pooled ODBC for Erlang

poolboy_odbc is a simple wrapper built on top of poolboy and the odbc library bundled with Erlang/OTP to pool ODBC connections.

Usage:

1> poolboy_odbc:start().
ok
2> poolboy_odbc_mgr:add_pool('odbc/pool1', [{size, 5}, {max_overflow, 10}],
    [{dsn, "DSN=pool1;UID=user;PWD=secret"}, {options, [
        {auto_commit, off},
        {binary_strings, on}]}]).
ok
3> Worker = poolboy_odbc:connect('odbc/pool1').
<0.31.0>
4> poolboy_odbc:sql_query(Worker, "SELECT * FROM test").
{selected, ["id", "name"],
           [{1, <<"Erika Mustermann">>}]}

You can now do all operations like in the odbc module, except you use the poolboy_odbc module and the Worker instead of the connection reference.

10> poolboy_odbc:disconnect('odbc/pool1', Worker).
ok

To reduce boilerplate code for connecting and safe disconnecting, you can use poolboy_odbc's do function. Previously the function was called safe_worker, which is now deprecated and will be removed with the next major release. The safe_worker function isn't able to return anything from the supplied function.

100> poolboy_odbc:do('odbc/pool1', fun(SafeWorker) ->
         {updated, 1} = poolboy_odbc:param_query(
            SafeWorker,
            "INSERT INTO TEST (name) VALUES (?)",
            [{{sql_varchar, 64}, [<<"Hans Dampf">>]}])
         end).
{ok, {updated, 1}}

101> poolboy_odbc:do('odbc/pool1', fun(SafeWorker) ->
        {selected, _ColumnNames, Result} = poolboy_odbc:sql_query(
            SafeWorker,
            "SELECT * FROM test"),
            Result
        end).
{ok,[{1,<<"Erika Mustermann">>}
     {2,<<"Hans Dampf">>}]}
102>

Authors:

Contributors:

Contributions are always very welcome! Here I just want to say thank you and give credit to people, who were contributing to the project.

In chronological order:

License:

poolboy_odbc is licensed under the MIT license from version 0.2.1 on, any version before that was licensed under the LGPL 3.0.

Something went wrong with that request. Please try again.