Skip to content

Suggestion for easier more Rust-like commands #170

Open

Description

@Raj2032

Hey @KyGost, I wanted to suggest improvements to multisql.

In this example:

use gluesql::prelude::*;

fn main() {
    let storage = SledStorage::new("data/doc-db").unwrap();
    let mut 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)

Unless if there was a way to do this already?

Activity

  1. KyGost commented on Jun 19, 2022

    @KyGost
    Member

    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::insert are better usable.

  2. Raj2032 commented on Jun 20, 2022

    @Raj2032
    Author

    @KyGost

    Hey @Raj2032, thanks! Great suggestion.

    No worries mate :)

    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

    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 glue sql in your repo?

  3. KyGost commented on Jun 20, 2022

    @KyGost
    Member

    @Raj2032

    Oh nice, is it ready for use?

    Yup

    Off topic over here but if multisql is different to glue sql, how come there are names with glue sql in your repo?

    When I rewrote things, I never bothered changing it. It never seemed inappropriate.

    Open to suggestions for alternatives.

  4. Raj2032 commented on Jun 20, 2022

    @Raj2032
    Author

    @KyGost

    Yup

    Oh nice mate. What about other things such as SELECT, CREATE TABLE etc?

    Is this also available to gluesql as well mate?

    When I rewrote things, I never bothered changing it. It never seemed inappropriate.

    Ah right mate got it :)

  5. KyGost commented on Jun 20, 2022

    @KyGost
    Member

    @Raj2032
    Not that I'm aware.

  6. Raj2032 commented on Jun 20, 2022

    @Raj2032
    Author

    @KyGost I see mate.

    for multisql do such macros such as SELECT, CREATE TABLE etc exist?

  7. KyGost commented on Jun 20, 2022

    @KyGost
    Member

    @Raj2032
    SELECT: Kinda

    Everything else is a TODO

  8. Raj2032 commented on Jun 20, 2022

    @Raj2032
    Author

    @KyGost AH right thanks mate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions