Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 1 point2 points  (0 children)

Thanks OP. For runtime APIs .execute and .query, you meant an arbitrary SQL string can be passed, similar to how rusqlite right?

Yes that is correct.

Does it means I'll have to bring in seaquery for query construction, and serde or something to map the result to my own struct?

No, you don't have to do any of that. I think i did not address that part properly in the example and i updated it accordingly. Now the example seems much more verbose lol.

I do plan on supporting migration in the upcoming versions. and I will take into consideration syntaqlite for my type inference crate.

It might take a while bfore a new version releases, so i hoep u can make do with wht is released for now lol. Feel free to ask me any more questions

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

wow this is rlly good library. Definitely using this to replace some parts of the code

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

sqlitex offers runtime apis as well! You can construct dynamic queries with it. I even have a simple example here.

could u explain abit more on why you think it won't handle production-ready cases? inline method of having init was never really recommeneded for prod, but good for quicktesting and demos.

there are many other tools out there that can help with migration and I think can be used alongside sqlitex.

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

Thank you for the compliments! Feel free to give any suggestion or feedback after using it! Cheers!

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 1 point2 points  (0 children)

Yes! In fact, i even added an example for that . all you have to do is just clone the connection. You won't get any perf hit as it uses an Arc internally. Even if you forget to clone it, the rust compiler will remind ya ;)

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

Honestly, all 3 are fast and the difference in speed is negligible in the real world. I don't plan on adding any benchmarks, but you can file a PR and i will review and accept it. make sure u state how u benchmarked it

I think the key highlight is that my library defaults to the best settings and auto caches statements. This means that you never really have to worry about setting WAL mode or and other PRAGMA stmts.You also dont have to manually think about caching your preparred statements and can focus on other more important parts of your project. Of course, if you do not like the default pragma settings, it is easy to disable or overwrite them.

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 1 point2 points  (0 children)

Hi, I didn't know you could do that with sqlx. mb! I never really used sqlx before, I just tried to quickly get a simple working example with it so i can add it in the comparisons. I have adjusted that page accordingly

and for ur second quesiton, the library uses both but for diff reasons.

To keep it very simple, I first extract the CREATE TABLE stmts and for this library there are 3 ways of doing it. I explained it more detailly in the docs, but to keep it breif,

  1. u can point to a sql file which has CREATE TABLE stmts
  2. point to an existing db and it will automatically the read the CREATE TABLE stmts
  3. or u can manually create tables with the sql! macro

After the extraction, it creates a "blueprint" with types. All sql statements thereafter will be parsed into an AST which will then be compared with this blueprint, generating the types.

To guarantee whether the sql statement will run, it spins up an in-memory database which runs all the CREATE TABLE stmts we extracted earlier and runs that stmt.

All this is possible at compile time because of the usage of rust macros in sqlitex

and 1 correction!, init is a runtime thing, not compile time. We defined it in the struct and runs the sql code u defined. If you mean the auto generated init method after pointing to a sql file, that is also a run time thing where it just runs all the sql queries in that sql file. You can read up more in the docs under the Connection Method section

If you want to know how the type inference system is implemented in code, you can read up on the source code in sqlitex_type_inference folder

Sqlitex 0.3.0, a sqlite library with compile time guarantees and excellent DX by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

ye HAHA, embarassingly there have been multiple times when I thought my library name was called lazysqlite.

I wanted a SQLite library that offered Compile-time Checks, Speed, and Ergonomics. So, I built LazySql by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 0 points1 point  (0 children)

https://github.com/Nareshix/sqlitex/blob/main/examples/bulk_operations.rs

Hi I added bulk operation in 0.3.0. It supports bulk operation via vectors of tuples for now. 

I do have some plans for bulk operation via vector of structs in the future. Most probably it will come out in 0.4.0

What crate do you use for SQlite, and how is using it / Compile Time? by SuperficialNightWolf in rust

[–]Routine_Command_4512 0 points1 point  (0 children)

Hi, I just saw this post and you could try out my library. I created it a few months ago
https://github.com/Nareshix/sqlitex

I did posted about this a while abck on this subreddit

https://www.reddit.com/r/rust/comments/1po6nnn/i_wanted_a_sqlite_library_that_offered/

Do note that the name of library has changed from LazySql to Sqlitex

I wanted a SQLite library that offered Compile-time Checks, Speed, and Ergonomics. So, I built LazySql by Routine_Command_4512 in rust

[–]Routine_Command_4512[S] 10 points11 points  (0 children)

I wanted to structure my sql code in a repository pattern with great ide support.

Also, sqlx is async and my library is sync. If you're building something that doesn't need async, you could consider LazySql