You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Check this out for the get up and running quickly example](https://github.com/brianc/node-postgres/wiki/Example)
41
42
42
-
### Simple
43
+
### Client instance
43
44
44
-
Sometimes you may not want to use a pool of connections. You can easily connect a single client to a postgres instance, run a query, and disconnect.
45
+
Sometimes you may not want to use a pool of connections. You can easily connect a single client to a postgres instance, run some queries, and disconnect.
45
46
46
47
```javascript
47
-
var pg =require('pg');
48
-
//or native libpq bindings
49
-
//var pg = require('pg').native
48
+
var pg =require('pg');
50
49
51
50
var conString ="postgres://username:password@localhost/database";
node-postgres contains a pure JavaScript driver and also exposes JavaScript bindings via libpq. You can use either interface. I personally use the JavaScript bindings as they are quite fast, and I like having everything implemented in JavaScript.
73
+
To install the [native bindings](https://github.com/brianc/node-pg-native.git):
74
+
75
+
```sh
76
+
$ npm install pg pg-native
77
+
```
78
+
75
79
76
-
To use native libpq bindings replace `require('pg')` with `require('pg').native`. If you __do not__ need or want the native bindings at all, consider using [node-postgres-pure](https://github.com/brianc/node-postgres-pure) instead which does not include them.
80
+
node-postgres contains a pure JavaScript protocol implementation which is quite fast, but you can optionally use native bindings for a 20-30% increase in parsing speed. Both versions are adequate for production workloads.
77
81
78
-
The two share the same interface so __no other code changes should be required__. If you find yourself having to change code other than the require statement when switching from `pg` to `pg.native` or `pg.js`, please report an issue.
82
+
To use the native bindings, first install [pg-native](https://github.com/brianc/node-pg-native.git). Once `pg-native` is installed, simply replace `require('pg')` with `require('pg').native`.
83
+
84
+
node-postgres abstracts over the [pg-native](https://github.com/brianc/node-pg-native.git) module to provide exactly the same interface as the pure JavaScript version. __No other code changes are required__. If you find yourself having to change code other than the require statement when switching from `require('pg')` to `require('pg').native` please report an issue.
79
85
80
86
## Features
81
87
@@ -90,19 +96,18 @@ The two share the same interface so __no other code changes should be required__
90
96
91
97
## Contributing
92
98
93
-
__I love contributions.__
99
+
__We love contributions!__
94
100
95
-
You are welcome contribute via pull requests. If you need help getting the tests running locally feel free to email me or gchat me.
101
+
If you need help getting the tests running locally or have any questions about the code when working on a patch please feel free to email me or gchat me.
96
102
97
103
I will __happily__ accept your pull request if it:
98
104
-__has tests__
99
105
- looks reasonable
100
106
- does not break backwards compatibility
101
-
- satisfies jshint
102
107
103
108
Information about the testing processes is in the [wiki](https://github.com/brianc/node-postgres/wiki/Testing).
104
109
105
-
If you need help or have questions about constructing a pull request I'll be glad to help out as well.
110
+
Open source belongs to all of us, and we're all invited to participate!
106
111
107
112
## Support
108
113
@@ -113,16 +118,15 @@ If at all possible when you open an issue please provide
113
118
114
119
Usually I'll pop the code into the repo as a test. Hopefully the test fails. Then I make the test pass. Then everyone's happy!
115
120
116
-
117
121
If you need help or run into _any_ issues getting node-postgres to work on your system please report a bug or contact me directly. I am usually available via google-talk at my github account public email address.
118
122
119
-
I usually tweet about any important status updates or changes to node-postgres.
123
+
I usually tweet about any important status updates or changes to node-postgres on twitter.
120
124
Follow me [@briancarlson](https://twitter.com/briancarlson) to keep up to date.
121
125
122
126
123
127
## Extras
124
128
125
-
node-postgres is by design _low level_ with the bare minimum of abstraction. These might help out:
129
+
node-postgres is by design pretty light on abstractions. These are some handy modules we've been using over the years to complete the picture:
126
130
127
131
-[brianc/node-pg-native](https://github.com/brianc/node-pg-native) - Simple interface abstraction on top of [libpq](https://github.com/brianc/node-libpq)
128
132
-[brianc/node-pg-query-stream](https://github.com/brianc/node-pg-query-stream) - Query results from node-postgres as a readable (object) stream
@@ -138,15 +142,6 @@ node-postgres is by design _low level_ with the bare minimum of abstraction. Th
138
142
-[datalanche/node-pg-format](https://github.com/datalanche/node-pg-format) - Safely and easily create dynamic SQL queries with this Node implementation of [PostgreSQL format()](http://www.postgresql.org/docs/9.3/static/functions-string.html#FUNCTIONS-STRING-FORMAT).
139
143
-[iceddev/pg-transact](https://github.com/iceddev/pg-transact) - A nicer API on node-postgres transactions
140
144
141
-
142
-
### Windows
143
-
144
-
1. Install Visual Studio C++ (successfully built with Express 2010). Express is free.
145
-
2. Add your Postgre Installation's `bin` folder to the system path (i.e. `C:\Program Files\PostgreSQL\9.3\bin`).
146
-
3. Make sure that both `libpq.dll` and `pg_config.exe` are in that folder.
147
-
4.`npm install pg`
148
-
149
-
150
145
## License
151
146
152
147
Copyright (c) 2010-2014 Brian Carlson (brian.m.carlson@gmail.com)
0 commit comments