# Rust-Postgres
A native PostgreSQL driver for Rust.
Documentation is available at https://sfackler.github.io/doc/postgres
[](https://travis-ci.org/sfackler/rust-postgres)
```toml
# Cargo.toml
[dependencies.postgres]
git = "https://github.com/sfackler/rust-postgres.git"
```
## Overview
Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database. It
exposes a high level interface in the vein of JDBC or Go's `database/sql`
package.
```rust
extern crate postgres;
extern crate time;
use time::Timespec;
use postgres::{Connection, SslMode};
struct Person {
id: i32,
name: String,
time_created: Timespec,
data: Option
More conversions can be defined by implementing the `ToSql` and `FromSql`
traits.
## Optional features
### UUID type
[UUID](http://www.postgresql.org/docs/9.4/static/datatype-uuid.html) support is
provided optionally by the `uuid` feature. It is enabled by default.
To disable support for optional features, add `default-features = false` to
your Cargo manifest:
```toml
[dependencies.postgres]
git = ...
default-features = false
features = [...]
```
## Development
Like Rust itself, Rust-Postgres is still in the early stages of development, so
don't be surprised if APIs change and things break. If something's not working
properly, file an issue or submit a pull request!
Rust Type
Postgres Type
bool
BOOL
i8
"char"
i16
SMALLINT, SMALLSERIAL
i32
INT, SERIAL
i64
BIGINT, BIGSERIAL
f32
REAL
f64
DOUBLE PRECISION
str/String
VARCHAR, CHAR(n), TEXT
[u8]/Vec<u8>
BYTEA
serialize::json::Json
JSON
time::Timespec
TIMESTAMP, TIMESTAMP WITH TIME ZONE
uuid::Uuid
(optional)
UUID
types::range::Range<i32>
INT4RANGE
types::range::Range<i64>
INT8RANGE
types::range::Range<Timespec>
TSRANGE, TSTZRANGE
types::array::ArrayBase<Option<bool>>
BOOL[], BOOL[][], ...
types::array::ArrayBase<Option<Vec<u8>>>
BYTEA[], BYTEA[][], ...
types::array::ArrayBase<Option<i8>>
"char"[], "char"[][], ...
types::array::ArrayBase<Option<i16>>
INT2[], INT2[][], ...
types::array::ArrayBase<Option<i32>>
INT4[], INT4[][], ...
types::array::ArrayBase<Option<String>>
TEXT[], CHAR(n)[], VARCHAR[], TEXT[][], ...
types::array::ArrayBase<Option<Json>>
JSON[], JSON[][], ...
types::array::ArrayBase<Option<i64>>
INT8[], INT8[][], ...
types::array::ArrayBase<Option<Timespec>>
TIMESTAMP[], TIMESTAMPTZ[], TIMESTAMP[][], ...
types::array::ArrayBase<Option<f32>>
FLOAT4[], FLOAT4[][], ...
types::array::ArrayBase<Option<f64>>
FLOAT8[], FLOAT8[][], ...
types::array::ArrayBase<Option<Range<i32>>>
INT4RANGE[], INT4RANGE[][], ...
types::array::ArrayBase<Option<Range<Timespec>>>
TSRANGE[], TSTZRANGE[], TSRANGE[][], ...
types::array::ArrayBase<Option<Range<i64>>>
INT8RANGE[], INT8RANGE[][], ...
std::collections::HashMap<String, Option<String>>
HSTORE