https://github.com/abzico/pqxx_pool
Demonstration of connection pool for libpqxx. Port from https://github.com/borisovs/pool to work with libpqxx. Tested on Ubuntu 16.04.
https://github.com/abzico/pqxx_pool
connection-pool cpp cxx libpqxx pg postgres postgresdb
Last synced: 2 months ago
JSON representation
Demonstration of connection pool for libpqxx. Port from https://github.com/borisovs/pool to work with libpqxx. Tested on Ubuntu 16.04.
- Host: GitHub
- URL: https://github.com/abzico/pqxx_pool
- Owner: abzico
- License: mit
- Created: 2018-07-05T20:58:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-05T22:41:52.000Z (almost 7 years ago)
- Last Synced: 2025-03-29T13:21:17.272Z (3 months ago)
- Topics: connection-pool, cpp, cxx, libpqxx, pg, postgres, postgresdb
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 13
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pqxx_pool
This project works on top of great work by borisovs (https://github.com/borisovs/pool) which directly use libpq's API via `libpq-fe.h` but
now this project call APIs through [libpqxx](https://github.com/jtv/libpqxx).# Tehnical
The implementation focuses on having connection pool which its number of available connection is set via `POOL_SIZE` in `PGPool.h` file. In `main.cpp`, it simulates creating a new 10 threads holding of each available connection from the pool to execute DB related task. Ideally, the concurrency model at this point is up to your app implementation. See more detail for possible ways at http://pqxx.org/development/libpqxx/wiki/Threading .
# What to do?
Create a database namely `demo` first by log in to your postgres console, and execute `create database demo`.
Then execute SQL statements from provided file (pool.sql) to insert necessary tables into such database as follows`psql -U postgres demo < pool.sql`
Then compile, link and make executable file via the following
`make`
It will produce an executable called `pool` at the same directory.
Finally run with
`PGDATABASE=demo PGUSER=postgres PGPASSWORD="...your password if any..." ./pool`
# License
MIT, Abzi.co