воскресенье, 6 февраля 2011 г.

node.js+postgresql

List of postgresql adapters for node.js:
https://github.com/ry/node_postgres
https://github.com/brianc/node-postgres - my select (the best)
https://github.com/creationix/postgres-js
https://github.com/aurynn/postgres-js

I execute command for use node-postgres:
npm install pg
 
example.js:
var pg = require('pg');
var connectionString = "pg://postgres:postgres@localhost:5432/test";
pg.connect(connectionString, function(err, client) {
    if (err) {
        console.log('fatal error');
    } else {
        client.query("select version();", function(err, result) {
            if (err) {
                console.log('error');
            } else {
                console.log(result);
            }
        });
    }
})

Комментариев нет:

Отправить комментарий