PostgreSQL native library for Tarantool programming language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
annelin c30322d30a Added tag v1.0 for changeset 0c14359b99a6 3 months ago
cmake Try to fix OpenSSL cmake recipe 3 months ago
debian Import from 8 months ago
pg_tarantool [FIX] hotfix in prepare() method 3 months ago
rpm Import from 8 months ago
test Fixed paths in CMakeList and compilation error 8 months ago
CMakeLists.txt Release v0.9 [No backward compatibility!] 3 months ago
Jenkinsfile Import from 8 months ago
LICENSE Import from 8 months ago Release v1.0-rc1 3 months ago
pg-tarantool-hg-999.rockspec Release v0.9 [No backward compatibility!] 3 months ago

pg-tarantool - PostgreSQL connector for Tarantool

Getting Started


  • Tarantool 1.10+ with headers (tarantool && tarantool-dev packages)
  • PostgreSQL 9.1+ headers (libpq-dev package)
  • OpenSSL headers (libssl-dev package)
  • libuuid headers (buuid-dev package)
  • Recommended: lua-cjon and lpeg


Clone repository and then build it using CMake:

hg clone
cd pg-tarantool && cmake . 
make install

You can also use LuaRocks:

luarocks install


pg = require('pg_tarantool')
link = pg.connect{host = '', port = 5432, user = 'user', pass = 'pass', db = 'db', sslmode = 'required', connections = 1}
data = link:query("SELECT 1 as ONE, '2' as TWOSTRING") 

API Documentation

Connect to a database.
Returns link (connections pool).


  • host - a hostname to connect
  • port - a port numner to connect
  • user - username
  • password - a password
  • dbname - a database name
  • sslmode - a ssl mode used in this connection (see Table 31-1. SSL Mode Descriptions) (default = ‘disable’)
  • connections - connection pool size (0 means do not create connection pool, just establish single connection) (default = ‘0’)


  • link, database connections pool,

Executes a statement with given arguments in printf-like style.
Arguments can be: numeric, string or table types. They will be escaped and formatted automatically.


  • {result1}, {result2}, ... on success
  • false, error description, on error


### `link:query("SELECT %d AS a, %s AS b", 42, 'string_value')
- - - a: 42
      b: "string_value"

Prepare a SQL statement.
If persistent set as true, this statement won’t be deallocated after execution.


  • statement object on success
  • false, error description, on error

Statement object methods:

  • execute(arg1, arg2...) — execute current statement with given arguments
  • deallocate() — immediately deallocate current statement


### `link:prepare("SELECT $1 AS a, $2 AS b"):execute(1, 'string_value') -- or link:prepare("SELECT $1 AS a, $2 AS b")(1, 'string_value')`  
- - - a: 42
      b: "string_value"

Closes database link.

Returns: nil

Writable variables

  • pg.types.null -- convert postgresql NULL to this value (default: nil).
  • pg.catch.error -- function called on SQL query failure (default: function() end)
  • pg.catch.debug -- function called on each SQL query (default: function() end) .

See Also