GithubHelp home page GithubHelp logo

hot-moms / puresql-rust Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

Pure (vec<u8> based) implementation of sql query builder on rust

Rust 100.00%
opinionated perfomance rust sql sql-builder unsafe unstable

puresql-rust's Introduction

puresql-rust

Pure (Vec[u&] based) opinionated implementation of SQL Query Builder on Rust

Install: puresql-rust = { git = "https://github.com/hot-moms/puresql-rust"}

puresql-rust is a lightweight and efficient SQL query builder written in Rust.

It offers a pure, lightweight string-based implementation for constructing SQL statements and queries. With puresql-rust, users can easily generate complex and robust SQL queries with a very unsafe, but simple and intuitive interface.

TODO:

  • ADD clauses
  • Equal to X
  • Contained by X
  • Any of X
  • Field is X (type)
  • Compare field with X
  • Between X and Y
  • OR clauses

Functions:

pub fn from(initial_query: &str) -> QueryBuilder
pub fn equal_to<T: ToSql + Sync>(&mut self, column_name: &str, object: Option<&'a T>)
pub fn field_is(&mut self, column_name: &str, is_null: bool)
pub fn compare_with(&mut self, column_name: &str, is_descending: bool, is_timestamp: bool)
pub fn any_of<T: ToSql + Sync + 'a>(&mut self, column_name: &str, objects: &'a Vec<T>)
pub fn contained_by<T: ToSql + Sync>
pub fn between(&mut self, column_name: &str, range: &'a RangeIncluse<i32>)
pub fn order_by(&mut self, sort_by: &str, ordering: &str, is_search: bool)
pub fn limit(&mut self, limit: u8)
pub fn offset(&mut self, offset: i32)
pub fn custom_query(&mut self, query_: &str)    <-- push your custom query

Example

Code:

    let mut sql = QueryBuilder::from(QUERY);          <-- QUERY - some basic query like 'SELECT * FROM something'
    sql.equal_to("item", [same as item column]);
    sql.contained_by(
        "some_array",
        [array],
        [bool: full_match?],
    );

    sql.any_of("anyof_array", [array]);
    sql.between("year", [rangeInclusive: 1000..2000]);


    await database.execute(&sql.query, &sql.params);  <-- special getters for query and params

2023, Archie Iwakura (hot-moms)

puresql-rust's People

Contributors

kitsuniru avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.