no mo glue

main
Bel LaPointe 2025-02-28 15:16:45 -07:00
parent 8ce43b449d
commit 71405ab25f
3 changed files with 11 additions and 3947 deletions

3913
src/rust/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,4 +5,3 @@ edition = "2024"
[dependencies]
futures = "0.3.31"
gluesql = { version = "0.16.3", features = ["gluesql_memory_storage"] }

View File

@ -1,52 +1,28 @@
mod main {
use {
gluesql::{
gluesql_memory_storage::MemoryStorage,
prelude::Glue,
core::store::{GStore, GStoreMut},
core::ast::Statement,
}
};
pub fn run() {
let mut db = DB::new(Glue::new(MemoryStorage::default()));
let mut db = DB::new(false);
db.init().expect("db init failed");
}
struct DB<T: GStore + GStoreMut> {
db: Glue<T>,
struct DB {
db: bool,
}
impl<T: GStore + GStoreMut> DB<T> {
fn new(db: Glue<T>) -> DB<T> {
impl DB {
fn new(db: bool) -> DB {
DB{db: db}
}
fn init(self: &mut DB<T>) -> Result<(), String> {
self.exec("DROP TABLE IF EXISTS t")?;
self.exec("DROP TABLE IF EXISTS t2")?;
self.exec("CREATE TABLE t (id INTEGER PRIMARY KEY, k TEXT, v TEXT)")?;
self.exec("CREATE TABLE t2 (id INTEGER PRIMARY KEY, t_id INTEGER, FOREIGN KEY (t_id) REFERENCES t (id))")?;
fn init(self: &mut DB) -> Result<(), String> {
//self.exec("DROP TABLE IF EXISTS t")?;
//self.exec("DROP TABLE IF EXISTS t2")?;
//self.exec("CREATE TABLE t (id INTEGER PRIMARY KEY, k TEXT, v TEXT)")?;
//self.exec("CREATE TABLE t2 (id INTEGER PRIMARY KEY, t_id INTEGER, FOREIGN KEY (t_id) REFERENCES t (id))")?;
Ok(())
}
fn exec(self: &mut DB<T>, q: &str) -> Result<(), String> {
futures::executor::block_on(async {
match self.db.execute(q).await {
Ok(_) => Ok(()),
Err(err) => Err(err.to_string())
}
})
}
fn insert(self: &mut DB<T>, q: &str) -> Result<(), String> {
futures::executor::block_on(async {
match self.db.execute(q).await {
Ok(_) => Ok(()),
Err(err) => Err(err.to_string())
}
})
}
}
}