Skip to content
Synchronous libpq binding for node.js.
JavaScript C++ Python
Find file
Latest commit 0ae0d0d Feb 22, 2015 Ray Kitajima bump version to 0.2.0
Failed to load latest commit information.
lib backward compatibility for old misspelled methods Nov 27, 2014
src migrated to node 0.12 Feb 22, 2015
test fixed various misspellings and inconsistencies Nov 26, 2014
.gitignore Update .gitignore Nov 26, 2014
README.md fixed various misspellings and inconsistencies Nov 26, 2014
binding.gyp make binding.gyp work with windows Oct 4, 2014
package.json

README.md

pg-sync

Synchronous, blocking libpq binding (PostgreSQL client) for node.js, based on Brian Carlson's node-postgres.

Preparation

This module requires libpq in your system.

wget http://ftp.postgresql.org/pub/source/<version>/postgresql-<version9>.tar.gz
tar zxvf postgresql-<version9>.tar.gz
cd postgresql-<version9>
./configure --prefix=/path/to/pgsql
make
make install

Installation

npm install pg-sync

Examples

var pgsync = require('pg-sync');
var client = new pgsync.Client();

client.connect("host=127.0.0.1 port=5432 dbname=mydb");

client.begin();
client.setIsolationLevelSerializable();

var result = client.query(queryText);
var result = client.query(queryText,[params]);

var result = client.exec(command); // returns result code only, even if the command was normal query

var statement = client.prepare(queryText);
var result = statement.execute([params]);

var queryName = "a_repeated_query";
var queryText = "delete from table where id=$1";
var statement = client.prepare(queryName,queryText);
[1,2,3,4].map( function(i){ statement.execute([i]); } );

client.commit();
client.rollback();

client.disconnect();

Note

Node 0.8, 0.10, 0.11+ supported.

This module does not support copy command.

See also

http://github.com/brianc/node-postgres

License

Copyright (c) 2013 Rei Kitajima (rei.kitajima@gmail.com)

MIT License

This product is almost based on Brian Carlson's node-postgres.

Copyright (c) 2010 Brian Carlson (brian.m.carlson@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.