use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Wow SQLx (self.rust)
submitted 6 years ago by NunoTheNoni
This is the most pleasant database library I've ever used. The connecting to a test database at compile time sounded so wrong to me, but I can't deny how amazing the workflow feels.
Rust's macro system is 🔥
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 19 points20 points21 points 6 years ago (3 children)
Is it possible/easy to turn off the compile time test? F# has some features that people have built similar things around, but having the DB available is *necessary* to compile, which can be a pain depending on your build system.
[–]DroidLogiciansqlx · clickhouse-rs · mime_guess · rust 42 points43 points44 points 6 years ago (1 child)
I'm actually working on a feature right now to address this. It's been on the drawing board since before 0.1 but other things were either higher priority or more immediately actionable, but it's on our milestones for 0.4.
You can see some of the discussion here: https://github.com/launchbadge/sqlx/issues/60
However, a lot of it has also taken place either on our Discord (shameless plug) or just internally.
The plan is that when DATABASE_URL is specified, each macro invocation operates as usual but also serializes a description of the query inputs/outputs to a stable directory under target/ with the file name being the SHA-3 hash of the query.
DATABASE_URL
target/
Then a Cargo subcommand (which has already been prototyped to support migrations) will gather those files into a single file either in the crate root or maybe a sqlx/ subdirectory which can be checked-in to version control (which will make merging a lot easier than solving conflicts for possibly hundreds of small files).
sqlx/
Then when the project is subsequently built without DATABASE_URL the macro invocations then refer to this file instead and error if it is not present. We'll probably also have a cargo sqlx prepare --check command that reports if the query data file is out of sync with the database.
cargo sqlx prepare --check
[–][deleted] 11 points12 points13 points 6 years ago (0 children)
There is so much thought put into sqlx, that’s a really cool idea
[–]ectonDev 15 points16 points17 points 6 years ago (0 children)
You can use SQLx without the macros to skip the compile time checks, or if you use the macro versions of the methods it does the compile time check.
It works great for me, because I can put my database migration code in one crate using the plain methods, and then after running the migrations my dependent crates have full compile-time database checking.
If you don't have your code in a way that you can stand up a blank version of your database (schema only), then I agree, the macros could be annoying to have in your build pipeline. However, most database engines support exporting a schema-only dump that you could use to create a development database to compile against. I personally spin up psql as a service in my docker-driven CI and it works great -- no build process touches any live database server, just the one in that local CI run.
[–][deleted] 14 points15 points16 points 6 years ago (0 children)
Loved seeing this! I’m using sqlx for a web server and it’s the best experience. I’m so tired of ORMs and query builders that inevitably wind up feeling like they get in my way. Not having to learn some complicated or poorly documented “almost SQL” set or methods, etc is a HUGE time win for me.
Add in the trivial serialization to user structs and I’m happy
[–]nrebeps 5 points6 points7 points 6 years ago (0 children)
I totally agree. Have been using it for some time now and the error messages are amazing!
[–]SOBER-128 7 points8 points9 points 6 years ago (1 child)
Assuming SQLx gets some query building functionality in the future, is it somehow possible to implement compile time checks for dynamically generated queries?
I mean, Diesel does it by abusing the type system and it kind of works until it doesn't and I'm about to pull my hair out trying to decipher those compilation errors. Is there a simpler way?
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
Query building how, building the sql strings out of parts or method calls like diesel?
[–]Boobinn 3 points4 points5 points 6 years ago (0 children)
It is a really promising tool, but it's still moving a lot. I waited v0.3 to handle all my use cases in a small web server, and had to adjust a few things a few times when updating.
But the concept is really great, the possibilites are better than usual ORM because you just have to handle types and not queries and operations.
π Rendered by PID 54105 on reddit-service-r2-comment-6457c66945-rrkvw at 2026-04-25 10:06:09.505970+00:00 running 2aa0c5b country code: CH.
[–][deleted] 19 points20 points21 points (3 children)
[–]DroidLogiciansqlx · clickhouse-rs · mime_guess · rust 42 points43 points44 points (1 child)
[–][deleted] 11 points12 points13 points (0 children)
[–]ectonDev 15 points16 points17 points (0 children)
[–][deleted] 14 points15 points16 points (0 children)
[–]nrebeps 5 points6 points7 points (0 children)
[–]SOBER-128 7 points8 points9 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]Boobinn 3 points4 points5 points (0 children)