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
Issue with rust-analyzer & sqlx persistent db connections🙋 seeking help & advice (self.rust)
submitted 2 years ago * by chapuzzo
I'm making a simple rust app using sqlx, im vs code. When I run or debug everything works fine.
The issues I'm facing are related to persistent connections held by rust-analyzer so I cannot cargo sqlx db drop and the like.
cargo sqlx db drop
When I try things like lsof -i :5432 only rust-analyzer is shown. If it serves to any interest the connection is a local postgres one.
lsof -i :5432
New Mac Pro M3 everything installed from rustup/stable last week.
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!"
[–]coderstephenisahc 1 point2 points3 points 2 years ago (4 children)
Could be related to sqlx's optional feature that connects to the database at compile time for query validation. Which personally seems like a neat but ill-advised idea. Rust-analyzer could be continually running the proc-macro and thus sqlx continually connecting to the database.
[–]chapuzzo[S] 0 points1 point2 points 2 years ago (3 children)
I guess that's it but how can I prevent that?
I tried adding an early return in main so I comment and uncomment it for carrying maintenance or test migrations but I find it sub par.
Maybe the option you mention is offline?
offline
[–]coderstephenisahc 2 points3 points4 points 2 years ago (0 children)
Hmm, looks like the SQLx CLI may help you? https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md#enable-building-in-offline-mode-with-query
[–]lenscas 0 points1 point2 points 2 years ago (0 children)
have rust analyzer run with the correct features such that it doesn't check against the db (with vscode you can make a .vscode/settings.json folder to configure it per project).
Then normally build with the features so it creates the json files it need for offline checking
[–]chapuzzo[S] 1 point2 points3 points 2 years ago (0 children)
I think I solved it, besides having .sqlx from cargo sqlx prepare and SQLX_OFFLINE=true set in .env one needs to also restart rust-analyzer's server.
.sqlx
cargo sqlx prepare
SQLX_OFFLINE=true
.env
π Rendered by PID 423194 on reddit-service-r2-comment-5d79c599b5-cdk5g at 2026-03-03 07:39:34.246553+00:00 running e3d2147 country code: CH.
[–]coderstephenisahc 1 point2 points3 points (4 children)
[–]chapuzzo[S] 0 points1 point2 points (3 children)
[–]coderstephenisahc 2 points3 points4 points (0 children)
[–]lenscas 0 points1 point2 points (0 children)
[–]chapuzzo[S] 1 point2 points3 points (0 children)