https://github.com/arxdeus/puresql-rust
Pure (vec<u8> based) implementation of sql query builder on rust
https://github.com/arxdeus/puresql-rust
opinionated perfomance rust sql sql-builder unsafe unstable
Last synced: 7 months ago
JSON representation
Pure (vec<u8> based) implementation of sql query builder on rust
- Host: GitHub
- URL: https://github.com/arxdeus/puresql-rust
- Owner: arxdeus
- Created: 2023-06-22T13:55:11.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-29T12:20:41.000Z (over 2 years ago)
- Last Synced: 2025-02-19T22:34:02.904Z (8 months ago)
- Topics: opinionated, perfomance, rust, sql, sql-builder, unsafe, unstable
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
- [X] ADD clauses
- [X] Equal to X
- [X] Contained by X
- [X] Any of X
- [X] Field is X (type)
- [X] Compare field with X
- [X] Between X and Y
- [ ] OR clauses### Functions:
```
pub fn from(initial_query: &str) -> QueryBuilder
pub fn equal_to(&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(&mut self, column_name: &str, objects: &'a Vec)
pub fn contained_by
pub fn between(&mut self, column_name: &str, range: &'a RangeIncluse)
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)_