You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion for easier more Rust-like commands #170
Hey @KyGost, I wanted to suggest improvements to multisql.
In this example:
use gluesql::prelude::*;fnmain(){let storage = SledStorage::new("data/doc-db").unwrap();letmut glue = Glue::new(storage);let sqls = vec!["DROP TABLE IF EXISTS Glue;","CREATE TABLE Glue (id INTEGER);","INSERT INTO Glue VALUES (100);","INSERT INTO Glue VALUES (200);","SELECT * FROM Glue WHERE id > 100;",];for sql in sqls {let output = glue.execute(sql).unwrap();println!("{:?}", output)}}
While this is great for basic stuff, I wanted to suggest a more cleaner alternative.
Here is my suggestion to use commands to execute stuff such as select etc etc. Here is my example (this is pseudo code):
glue.drop(["Glue"]);
glue.create("Glue",vec![id:INTEGER]);// Takes two arguments, one is for the table name, the other is for column names
glue.insert("Glue",vec!(100);
glue.insert("Glue",vec!(200);
glue.select("Glue",["*"],[id > 100, id == 100];// table_name, columns, condition(s)
Activity
KyGost commentedon Jun 19, 2022
Hey @Raj2032, thanks! Great suggestion.
I've already been working on this in a way, with macros like:
https://github.com/MultiSQL/multisql/blob/main/tests/api/insert.rs#L11
And, in the process, I've been cleaning up the API so things like
Glue::insertare better usable.Raj2032 commentedon Jun 20, 2022
@KyGost
No worries mate :)
Oh nice, is it ready for use?
Off topic over here but if multisql is different to glue sql, how come there are names with
gluesql in your repo?KyGost commentedon Jun 20, 2022
@Raj2032
Yup
When I rewrote things, I never bothered changing it. It never seemed inappropriate.
Open to suggestions for alternatives.
Raj2032 commentedon Jun 20, 2022
@KyGost
Oh nice mate. What about other things such as
SELECT,CREATE TABLEetc?Is this also available to
gluesqlas well mate?Ah right mate got it :)
KyGost commentedon Jun 20, 2022
@Raj2032
Not that I'm aware.
Raj2032 commentedon Jun 20, 2022
@KyGost I see mate.
for multisql do such macros such as SELECT, CREATE TABLE etc exist?
KyGost commentedon Jun 20, 2022
@Raj2032
SELECT: KindaEverything else is a TODO
Raj2032 commentedon Jun 20, 2022
@KyGost AH right thanks mate