Subversion Repositories SE.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
50 7u83 1
pgapp
2
=====
3
 
4
This code is a front end for epgsql that adds a pool (poolboy, for the
5
moment), and code to isolate crashes in the epgsql library: if your
6
database goes down, you probably don't want the rest of the
7
application to fail as well.
8
 
9
Build and start the application with Make:
10
 
11
    - Copy and/or rename the file `pgapp.config.sample` into `pgapp.config`
12
    - Enter your configuration data in `pgapp.config`
13
    - Run:
14
 
15
        ~:$ make
16
        ~:$ make run
17
 
18
    - To test it, just run:
19
 
20
        > pgapp:equery(a_pool_name, "select current_date", []).
21
 
22
      where `a_pool_name` is the name of one of the pools in your `pgapp.config` file.
23
 
24
API use:
25
    - Simple pool:
26
 
27
        application:ensure_all_started(pgapp).
28
        pgapp:connect([{size, 10}, {database, "mydb"}, {username, "foo"}, {password, "bar"}]).
29
        pgapp:equery("select current_date", []),
30
        pgapp:with_transaction(fun() ->
31
                                     pgapp:squery("update ..."),
32
                                     pgapp:squery("delete from ..."),
33
                                     pgapp:equery("select ? from ?", ["*", Table])
34
                               end).
35
 
36
    - Multi pool:
37
 
38
        application:ensure_all_started(pgapp).
39
        pgapp:connect(a_pool_name, [{size, 10}, {database, "mydb"}, {username, "foo"}, {password, "bar"}]).
40
        pgapp:equery(a_pool_name, "select current_date", []).
41
 
42
The equery and squery API's are the same as those of epgsql: https://github.com/epgsql/epgsql
43
 
44
**Note**: It is still experimental, and is likely to break.  The API
45
is not stable!
46
 
47
See [Changelog].