sqlx-firebirdsql 0.1.0

Firebird SQL driver for SQLx
docs.rs failed to build sqlx-firebirdsql-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

sqlx-firebirdsql

A Firebird database driver for SQLx, the async Rust SQL toolkit.

Built on top of firebirust (a pure-Rust Firebird client library), this crate integrates Firebird as a first-class SQLx database backend.

Features

  • Async connections via Tokio
  • Connection pooling (FirebirdPool)
  • Transactions
  • Migrations (migrate feature)
  • Any driver support (any feature)
  • Type-safe query parameter binding with ? placeholders

Connection URL

firebird://user:password@host:port/path/to/database.fdb

The default connection parameters are:

Parameter Default
Host localhost
Port 3050
Username SYSDBA
Password masterkey
Wire crypt true
Auth plugin Srp256

Usage

Add the dependency to your Cargo.toml:

[dependencies]
sqlx-firebirdsql = "0.1"
sqlx-core = { version = "0.9.0-alpha.1", features = ["_rt-tokio"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Connecting and querying

use sqlx_core::connection::ConnectOptions;
use sqlx_core::executor::Executor;
use sqlx_core::row::Row;
use sqlx_firebirdsql::FirebirdConnectOptions;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let opts = FirebirdConnectOptions::new()
        .host("localhost")
        .port(3050)
        .username("SYSDBA")
        .password("masterkey")
        .database("/tmp/my_database.fdb");

    let mut conn = opts.connect().await?;

    conn.execute("CREATE TABLE test (id INTEGER NOT NULL, name VARCHAR(100))".into())
        .await?;

    Ok(())
}

Connecting with a URL

use std::str::FromStr;
use sqlx_core::connection::ConnectOptions;
use sqlx_firebirdsql::FirebirdConnectOptions;

let opts = FirebirdConnectOptions::from_str(
    "firebird://SYSDBA:masterkey@localhost:3050//tmp/my_database.fdb"
)?;
let mut conn = opts.connect().await?;

Type Mapping

Core types

Rust type Firebird type(s)
bool BOOLEAN
i8, i16 SMALLINT
i32 INTEGER
i64 BIGINT
u8 SMALLINT
u16 INTEGER
u32 BIGINT
u64 BIGINT (Decode only; may overflow)
f32 FLOAT
f64 DOUBLE PRECISION
&str, String VARCHAR, CHAR
&[u8], Vec<u8> BLOB

chrono feature

Requires the chrono Cargo feature flag.

Rust type Firebird type(s)
chrono::NaiveDate DATE
chrono::NaiveTime TIME
chrono::NaiveDateTime TIMESTAMP
chrono::DateTime<chrono::Utc> TIMESTAMP

rust_decimal feature

Requires the rust_decimal Cargo feature flag.

Rust type Firebird type(s)
rust_decimal::Decimal NUMERIC, DECIMAL, DECFLOAT

Nullable

Option<T> is supported where T implements Type. An Option<T> represents a potentially NULL value from Firebird.

Feature Flags

Feature Description
any Enable the SQLx Any database driver
json Enable JSON serialization support
migrate Enable database migrations
offline Enable offline query checking
chrono Enable chrono date/time type conversions
rust_decimal Enable rust_decimal numeric type conversions

License

Licensed under either of

at your option.