Crates.io | fnck_sql |
lib.rs | fnck_sql |
version | |
source | src |
created_at | 2024-01-28 19:12:09.551653 |
updated_at | 2024-11-03 09:53:28.343994 |
description | SQL as a Function for Rust |
homepage | |
repository | https://github.com/KipData/KipSQL |
max_upload_size | |
id | 1117798 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Built by @KipData ███████╗███╗ ██╗ ██████╗██╗ ██╗ ███████╗ ██████╗ ██╗ ██╔════╝████╗ ██║██╔════╝██║ ██╔╝ ██╔════╝██╔═══██╗██║ █████╗ ██╔██╗ ██║██║ █████╔╝ ███████╗██║ ██║██║ ██╔══╝ ██║╚██╗██║██║ ██╔═██╗ ╚════██║██║▄▄ ██║██║ ██║ ██║ ╚████║╚██████╗██║ ██╗ ███████║╚██████╔╝███████╗ ╚═╝ ╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝ ╚══════╝ ╚══▀▀═╝ ╚══════╝ ----------------------------------- 🖕
FnckSQL 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.
Tips: Install rust toolchain and llvm first.
Clone the repository
git clone https://github.com/KipData/FnckSQL.git
let fnck_sql = DataBaseBuilder::path("./data").build()?;
let tuples = fnck_sql.run("select * from t1")?;
run cargo run --features="net"
to start server
then use psql
to enter sql
Storage Support:
docker pull kould23333/fncksql:latest
git clone https://github.com/KipData/FnckSQL.git
cd FnckSQL
docker build -t kould23333/fncksql:latest .
We installed the psql
tool in the image for easy debug.
You can use psql -h 127.0.0.1 -p 5432
to do this.
docker run -d \
--name=fncksql \
-p 5432:5432 \
--restart=always \
-v fncksql-data:/fnck_sql/fncksql_data \
-v /etc/localtime:/etc/localtime:ro \
kould23333/fncksql:latest
features = ["macros"]
#[derive(Default, Debug, PartialEq)]
struct MyStruct {
c1: i32,
c2: String,
}
implement_from_tuple!(
MyStruct, (
c1: i32 => |inner: &mut MyStruct, value| {
if let DataValue::Int32(Some(val)) = value {
inner.c1 = val;
}
},
c2: String => |inner: &mut MyStruct, value| {
if let DataValue::Utf8(Some(val)) = value {
inner.c2 = val;
}
}
)
);
features = ["macros"]
scala_function!(TestFunction::test(LogicalType::Integer, LogicalType::Integer) -> LogicalType::Integer => |v1: ValueRef, v2: ValueRef| {
let plus_binary_evaluator = EvaluatorFactory::binary_create(LogicalType::Integer, BinaryOperator::Plus)?;
let value = plus_binary_evaluator.binary_eval(&v1, &v2);
let plus_unary_evaluator = EvaluatorFactory::unary_create(LogicalType::Integer, UnaryOperator::Minus)?;
Ok(plus_unary_evaluator.unary_eval(&value))
});
let fnck_sql = DataBaseBuilder::path("./data")
.register_scala_function(TestFunction::new())
.build()?;
features = ["macros"]
table_function!(MyTableFunction::test_numbers(LogicalType::Integer) -> [c1: LogicalType::Integer, c2: LogicalType::Integer] => (|v1: ValueRef| {
let num = v1.i32().unwrap();
Ok(Box::new((0..num)
.into_iter()
.map(|i| Ok(Tuple {
id: None,
values: vec![
Arc::new(DataValue::Int32(Some(i))),
Arc::new(DataValue::Int32(Some(i))),
]
}))) as Box<dyn Iterator<Item = Result<Tuple, DatabaseError>>>)
}));
let fnck_sql = DataBaseBuilder::path("./data")
.register_table_function(MyTableFunction::new())
.build()?;
FnckSQL uses the Apache 2.0 license to strike a balance between open contributions and allowing you to use the software however you want.