Skip to main content

Crate kite_sql

Crate kite_sql 

Source
Expand description

KiteSQL is a high-performance SQL database that can be embedded in Rust code (based on RocksDB by default), making it possible to call SQL just like calling a function. It supports most of the syntax of SQL 2016.

KiteSQL provides thread-safe API: DataBase::run for running SQL

KiteSQL uses DataBaseBuilder for instance construction, configuration in builder mode

Support type

  • SqlNull
  • Boolean
  • Tinyint
  • UTinyint
  • Smallint
  • USmallint
  • Integer
  • UInteger
  • Bigint
  • UBigint
  • Float
  • Double
  • Char
  • Varchar
  • Date
  • DateTime
  • Time
  • Tuple

support optimistic transaction with the Database::new_transaction method.

support UDF (User-Defined Function) so that users can customize internal calculation functions with the DataBaseBuilder::register_function

§Examples

use kite_sql::db::{DataBaseBuilder, ResultIter};
use kite_sql::errors::DatabaseError;
use kite_sql::Model;

#[derive(Default, Debug, PartialEq, Model)]
#[model(table = "my_struct")]
struct MyStruct {
    #[model(primary_key)]
    pub c1: i32,
    pub c2: String,
}

#[cfg(feature = "orm")]
fn main() -> Result<(), DatabaseError> {
    let database = DataBaseBuilder::path("./hello_world").build()?;

    database.create_table_if_not_exists::<MyStruct>()?;
    database.insert(&MyStruct {
        c1: 0,
        c2: "zero".to_string(),
    })?;
    database.insert(&MyStruct {
        c1: 1,
        c2: "one".to_string(),
    })?;

    for row in database.fetch::<MyStruct>()? {
        println!("{:?}", row?);
    }
    database.drop_table::<MyStruct>()?;

    Ok(())
}

Modules§

binder
catalog
db
errors
execution
expression
macros
parser
planner
serdes
storage
types

Macros§

from_tuple
Examples
impl_transaction
implement_num_serialization
implement_ptr_serialization
implement_serialization_by_bincode
numeric_binary_evaluator_definition
numeric_unary_evaluator_definition
scala_function
Examples
single_mapping
table_function
Examples
throw