pg
Version, currently 0.12.027 versions
- 0.14.1latestDec 31, 2017
- 0.14.0not indexedJun 18, 2020
- 0.13.4not indexedJun 18, 2020
- 0.13.3not indexedJun 18, 2020
- 0.13.2not indexedJun 18, 2020
- 0.13.1not indexedJun 18, 2020
- 0.13.0not indexedJun 18, 2020
- 0.12.0not indexedJun 18, 2020
- 0.11.0not indexedJun 18, 2020
- 0.10.0not indexedJun 18, 2020
- 0.9.1not indexedJun 18, 2020
- 0.9.0not indexedJun 18, 2020
- 0.8.0not indexedJun 18, 2020
- 0.7.1not indexedJun 18, 2020
- 0.7.0not indexedJun 18, 2020
- 0.6.1not indexedJun 18, 2020
- 0.6.0not indexedJun 18, 2020
- 0.5.0not indexedJun 18, 2020
- 0.4.3not indexedJun 18, 2020
- 0.4.2not indexedJun 18, 2020
- 0.4.1not indexedJun 18, 2020
- 0.4.0not indexedJun 18, 2020
- 0.3.2not indexedJun 18, 2020
- 0.3.1not indexedJun 18, 2020
- 0.3.0not indexedJun 18, 2020
- 0.2.0not indexedJun 18, 2020
- 0.1.0not indexedJun 18, 2020
github.com/greenbigfrog/crystal-pg
a postgres driver for crystal
Nothing has been indexed for 0.12.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
pg:
github: greenbigfrog/crystal-pg
version: ~> 0.12.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.12.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
crystal-pg
A native, non-blocking Postgres driver for Crystal
usage
This driver now uses the crystal-db project. Documentation on connecting,
querying, etc, can be found at:
- https://crystal-lang.org/docs/database/
- https://crystal-lang.org/docs/database/connection_pool.html
shards
Add this to your shard.yml and run crystal deps
dependencies:
pg:
github: will/crystal-pg
Listen/Notify
There are two ways to listen for notifications. For docs on NOTIFY, please
read https://www.postgresql.org/docs/current/static/sql-notify.html.
- Any connection can be given a callback to run on notifications. However they are only received when other traffic is going on.
- A special listen-only connection can be established for instant notification
processing with
PG.connect_listen.
# see full example in examples/listen_notify.cr
PG.connect_listen("postgres:///", "a", "b") do |n| # connect and listen on "a" and "b"
puts " got: #{n.payload} on #{n.channel}" # print notifications as they come in
end
Arrays
Crystal-pg supports several popular array types. If you only need a 1 dimensional array, you can cast down to the appropriate Crystal type:
PG_DB.query_one("select ARRAY[1, null, 3]", &.read(Array(Int32?))
# => [1, nil, 3]
PG_DB.query_one("select '{hello, world}'::text[]", &.read(Array(String))
# => ["hello", "world"]
Requirements
Crystal-pg is tested on Postgres versions 9.2 through 9.6. Since it uses protocol version 3, older versions probably also work but are not guaranteed.
Supported Datatypes
- text
- boolean
- int8, int4, int2
- float4, float8
- timestamptz, date, timestamp (but no one should use ts when tstz exists!)
- json and jsonb
- uuid
- bytea
- numeric/decimal (1)
- varchar
- regtype
- geo types: point, box, path, lseg, polygon, circle, line
- array types: int8, int4, int2, float8, float4, bool, text
1: A note on numeric: In Postgres this type has arbitrary precision. In this
driver, it is represented as a PG::Numeric which retains all precision, but
if you need to do any math on it, you will probably need to cast it to a
float first. If you need true arbitrary precision, you can optionally
require pg_ext/big_rational which adds #to_big_r, but requires that you
have LibGMP installed.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.12.0- Tagged
- Jun 18, 2020
- Commit
cafeffddc6d9- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/greenbigfrog/crystal-pg
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 27