home.social

#sqlx — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #sqlx, aggregated by home.social.

fetched live
  1. Я люблю SQL, но устал собирать WHERE через fmt.Sprintf: зачем я сделал qrafter

    Мне нравится чистый SQL. Не «нравится, потому что пришлось», а правда нравится. В хорошем SQL‑запросе видно, что происходит с данными: откуда берём, как фильтруем, где соединяем, что агрегируем и в каком порядке отдаём наружу. Но как только в API появляются фильтры, сортировка, пагинация и отдельный COUNT(*) с тем же WHERE, чистый SQL быстро обрастает ручной бухгалтерией: args, placeholder«ы, fmt.Sprintf и копирование условий между запросами.» В какой‑то момент я понял, что меня раздражает не SQL. Меня раздражает работа вокруг SQL. Так появился qrafter — небольшой type‑safe SQL query builder для Go: без ORM, без codegen, с типизированными колонками, зависимым от диалекта рендером и обычным SQL + аргументами на выходе.

    habr.com/ru/articles/1042578/

    #golang #sql #postgresql #sqlx #querybuilder #opensource #typesafe

  2. Do i know any SQLX magicians?

    We have an issue over at codeberg.org/Chfkch/bitritter/ and not sure why SQLX cannot create the database on the fly on some machines. I am pretty sure it worked at some point in time, but since i cannot reproduce it on my computer (several people can), i am out of ideas.

    :boost_ok: :boostRequest:

    #SQLX #BitRitter #RustLang

  3. Do i know any SQLX magicians?

    We have an issue over at codeberg.org/Chfkch/bitritter/ and not sure why SQLX cannot create the database on the fly on some machines. I am pretty sure it worked at some point in time, but since i cannot reproduce it on my computer (several people can), i am out of ideas.

    :boost_ok: :boostRequest:

    #SQLX #BitRitter #RustLang

  4. I use #sqlx, and I wanted syntax highlighting for embedded #SQL queries in my #Rust code. Making that work in #Neovim led me to learning a few things about #Treesitter, and #NixOS packaging conventions. Here's my write-up!

    Public replies to this post will appear in a comments section under the blog post.

    sitr.us/2026/05/03/embedded-sq

  5. I use #sqlx, and I wanted syntax highlighting for embedded #SQL queries in my #Rust code. Making that work in #Neovim led me to learning a few things about #Treesitter, and #NixOS packaging conventions. Here's my write-up!

    Public replies to this post will appear in a comments section under the blog post.

    sitr.us/2026/05/03/embedded-sq

  6. Модно не значит правильно — про pgx, метрики и OpenTelemetry

    Один вопрос про pgx — и три инструмента которые легко перепутать. QueryTracer не замена декоратору, декоратор не устарел, а выбор драйвера — неожиданно важное решение для observability. Какую комбинацию драйвера и обёртки выбрать — зависит от того что вы хотите видеть. В статье взгляд на комбинации драйверов и оболочек для анализа запросов в PostgreSQL. Разбираем на реальном проекте — с кодом, ошибками и выводами. Лучше один раз разобраться, чем каждый раз сомневаться в выборе.

    habr.com/ru/articles/1024854/

    #pgx #sqlx #OpenTelemetry #Prometheus #observability #трейсинг #метрики #QueryTracer #otelsql #otelpgx

  7. for rust backend devs: try out clorinde (github)!

    it's a maintained fork of cornucopia, and the main premise as opposed to e.g. sqlx is that you have your queries in separate .sql files that the tool then generates bindings for!

    example: if you have this in queries/users.sql:

    --! get_followers_by_user_id
    select f.follow_state,
    f.follower_id,
    u.user_display_name
    from follower f
    left join user u on f.follower_id = u.user_id
    where f.followee_id = :id

    (the --! part is important! it sets the query name, and is also used for specifying nullable result fields/args)

    clorinde will generate a new crate in your project with a wrapper over every query that you can use e.g. like this:

    // ...
    let followers = users::get_followers_by_user_id()
    .bind(&pg_client, user_id)
    .all().await;

    for fw in follower {
    println!("{:?}", fw);
    }

    hehe i use hashtags now:
    #rust #backend #sqlx

  8. for rust backend devs: try out clorinde ([github](github.com/halcyonnouveau/clorinde))!

    it's a maintained fork of cornucopia, and the main premise as opposed to e.g. sqlx is that you have your queries in separate .sql files that the tool then generates bindings for!

    example: if you have this in queries/users.sql:

    --! get_followers_by_user_id
    select f.follow_state,
    f.follower_id,
    u.user_display_name
    from follower f
    left join user u on f.follower_id = u.user_id
    where f.followee_id = :id

    (the --! part is important! it sets the query name, and is also used for specifying nullable result fields/args)

    clorinde will generate a new crate in your project with a wrapper over every query that you can use e.g. like this:

    // ...
    let followers = users::get_followers_by_user_id()
    .bind(&pg_client, user_id)
    .all().await;

    for fw in follower {
    println!("{:?}", fw);
    }

    hehe i use hashtags now:
    #rust #backend #sqlx

  9. I built a little rust server that exposes a little website. Whenever I insert or update a task in the Postgres database, it automatically updates on the website. The whole thing is powered my pg_notify and SSE. This was very quick to build and works wonderfully!

    #postgresql #sse #sqlx

  10. I built a little rust server that exposes a little website. Whenever I insert or update a task in the Postgres database, it automatically updates on the website. The whole thing is powered my pg_notify and SSE. This was very quick to build and works wonderfully!

    #postgresql #sse #sqlx

  11. #SQL interfaces could use a way to conditionally enable statement rows. If one writes query by hand you enable or disable statements with just adding "--" at the beginning of the line

    SELECT * FROM example
    WHERE 1=1
    AND a = ?
    AND b = ?
    -- AND c = ?
    AND d = ?
    AND e = ?

    Similarily programming interface could have option for this, I don't see many query builders doing this ergonomically.

    In #TypeScript there is way with template literals, not with #Rust #SQLX

  12. #SQL interfaces could use a way to conditionally enable statement rows. If one writes query by hand you enable or disable statements with just adding "--" at the beginning of the line

    SELECT * FROM example
    WHERE 1=1
    AND a = ?
    AND b = ?
    -- AND c = ?
    AND d = ?
    AND e = ?

    Similarily programming interface could have option for this, I don't see many query builders doing this ergonomically.

    In #TypeScript there is way with template literals, not with #Rust #SQLX

  13. @khleedril To certain extent you can change the backend support, and your app shall work with other database.
    #Diesel role is not to abstract what db you're using, but how you're using it, so your data is modelled in your application.

    However, saying so I observe more and more people move away from such approach in favour of more data-centric approach and prefer #sqlx in result.

  14. @khleedril To certain extent you can change the backend support, and your app shall work with other database.
    #Diesel role is not to abstract what db you're using, but how you're using it, so your data is modelled in your application.

    However, saying so I observe more and more people move away from such approach in favour of more data-centric approach and prefer #sqlx in result.

  15. I've been playing with #RustLang again.
    Using #Axum #Handlebars #Htmx #Sqlx and #Sqlite
    It's a really joyful environment to work with. I'm finding it far easier than last time, a combination of much improved compiler errors, clippy guidance, #VSCode also seems to have improved understanding of the code (I'm not using #AI just Rust-Analyser and Even Better TOML
    Plus I'm building depth rather than width, fits much better for exploration and learning.
    The amount of syntax feels much reduced :-)

  16. I've been playing with #RustLang again.
    Using #Axum #Handlebars #Htmx #Sqlx and #Sqlite
    It's a really joyful environment to work with. I'm finding it far easier than last time, a combination of much improved compiler errors, clippy guidance, #VSCode also seems to have improved understanding of the code (I'm not using #AI just Rust-Analyser and Even Better TOML
    Plus I'm building depth rather than width, fits much better for exploration and learning.
    The amount of syntax feels much reduced :-)

  17. Kalorik: Telegram-бот на Rust для анализа питания

    В данной статье мы рассмотрим архитектуру и реализацию Telegram-бота Kalorik , написанного на языке программирования Rust. Этот бот предоставляет пользователям возможность анализировать свой рацион питания, получая автоматический расчёт калорий, макроэлементов и индекса массы тела. Особенностью проекта является использование современного стека на основе tokio , sqlx , teloxide , а также продуманная архитектура с учётом масштабируемости.

    habr.com/ru/articles/910298/

    #Rust #Telegram #Боты #SQLx #PostgreSQL #AI #Машинное_обучение #OpenAI #Tokio #Асинхронное_программирование

  18. Dear #axum + #sqlx users, has anyone managed to put a `Pool<DB>` (generic!) into your app state (`.with_state` on the router)?
    #rust

  19. `cargo audit` reports a vulnerability in a transient dependency that isn't in the output of `cargo tree`. What's going on here?
    #RustLang #CargoAudit #sqlx #Rust

  20. `cargo audit` reports a vulnerability in a transient dependency that isn't in the output of `cargo tree`. What's going on here?
    #RustLang #CargoAudit #sqlx #Rust

  21. Удобное сканирование в структуры в связке Go/PgX. Решение проблемы сканирования в PgX. Golang

    Go. PgxWrappy как решение всех проблем PgX. Если вы сталкивались с неудобным сканом в структуры посредством PgX на Go, то гляньте эту либу. Она решает все проблемы сканинга.

    habr.com/ru/articles/895298/

    #Golang #go #pgx #го #орм_в_го #golang_orm #orm #driver #sql #sqlx

  22. If anyone has a working example of #sqlx, #sqlite, and the #chrono DateTime (or NaiveDateTime) types working together, I'd be really glag... 🙄

    #rustlang

  23. If anyone has a working example of #sqlx, #sqlite, and the #chrono DateTime (or NaiveDateTime) types working together, I'd be really glag... 🙄

    #rustlang

  24. Tips for using the #Rust #Sqlx CLI: If you create the first migration without the `-r` flag, all subsequent migrations will be single files, even if you use the `-r` argument later. Therefore, remember to run `sqlx migrate add -r init` when creating the first migration if you want the ability to revert migrations.

  25. If you want to hang out with me and a bunch of cool humans, come join my #Zulip server!

    zulip.memorici.de/join/jcl42ys

    Invite active for 10 days.

    Here are some topics in #general stream:

    general

    #sqlx
    Axiom of Choice
    #Nix General
    Music
    Memes
    Algorithms and data structures
    Books
    Links we found
    AI Wins
    TIL
    MIT Puzzle 2025
    90 minutes of music
    Links from Small Internet
    Playwright
    AI Fails
    Flood
    Arts and crafs
    new streams
    Logjam as a metaphor
    Comic books
    React
    GDPR
    Nix Rust
    OSINT
    Are software developers joking or are they serious?
    Tool: Synergy (Share Mouse and Keyboard)
    Git stuff
    UX Fails
    CPU Performance in Cloud
    Fresh papers
    TypeScript: Newtype pattern
    Type bridges
    Mac OS WSL Nix
    Nix Configs
    UX
    VSCode
    Strategy

  26. If you want to hang out with me and a bunch of cool humans, come join my #Zulip server!

    zulip.memorici.de/join/jcl42ys

    Invite active for 10 days.

    Here are some topics in #general stream:

    general

    #sqlx
    Axiom of Choice
    #Nix General
    Music
    Memes
    Algorithms and data structures
    Books
    Links we found
    AI Wins
    TIL
    MIT Puzzle 2025
    90 minutes of music
    Links from Small Internet
    Playwright
    AI Fails
    Flood
    Arts and crafs
    new streams
    Logjam as a metaphor
    Comic books
    React
    GDPR
    Nix Rust
    OSINT
    Are software developers joking or are they serious?
    Tool: Synergy (Share Mouse and Keyboard)
    Git stuff
    UX Fails
    CPU Performance in Cloud
    Fresh papers
    TypeScript: Newtype pattern
    Type bridges
    Mac OS WSL Nix
    Nix Configs
    UX
    VSCode
    Strategy

  27. Why do portions of my result object from a sqlx::query_as INNER JOIN where all the fields/columns are NOT NULL force me to have Option-wrapping the subquery bits? Is that a bug?
    I'm not actually good at SQL, so I could be wrong, but an INNER JOIN means that we're guaranteed to have all the columns, right?
    #Rust #RustLang #sqlx #sqlite #sql

  28. Why do portions of my result object from a sqlx::query_as INNER JOIN where all the fields/columns are NOT NULL force me to have Option-wrapping the subquery bits? Is that a bug?
    I'm not actually good at SQL, so I could be wrong, but an INNER JOIN means that we're guaranteed to have all the columns, right?
    #Rust #RustLang #sqlx #sqlite #sql

  29. #Rust#sqlx 又是一個改變世界的開發工具,各個其他程式語言都相繼在仿造。 Go 的話走得比較前,sqlc 已經是可用的程式,但個人認為sqlx是最舒服最好用。無容置疑是gamechanger。就算它不支持Oracle,都值得為它放弃Oracle改用Postgresql

  30. #Rust#sqlx 又是一個改變世界的開發工具,各個其他程式語言都相繼在仿造。 Go 的話走得比較前,sqlc 已經是可用的程式,但個人認為sqlx是最舒服最好用。無容置疑是gamechanger。就算它不支持Oracle,都值得為它放弃Oracle改用Postgresql

  31. So, #sqlx for #rust #RustLang is pretty great actually. Compile-time checked queries are a huge win for reliability! I love being able to check my queries at compile time while I'm developing. :blobcatheart: Huge benefit there!

    The trouble I've found so far with this approach is there's not a good way to turn it off when you don't need it!

    Downstream consumers of my library crates must compile from source (because ... Rust), but they really don't need to double-check my queries, because I already did it before I committed the code. It's just completely unnecessary for every library consumer to re-check the queries again for the same code.

    Tragically, sqlx still forces downstream consumers to check the queries anyway, and requires them to have all the query metadata necessary to do that. So as a library author, I need to do a bunch of extra work to enable that step, even tho it's reaaaaally not needed. :blobcatverysad:

    Yes, sqlx has an offline mode that is supposed to make this easier. And maybe it does for the postgres types. But it's actually pretty complicated to get that working since it requires a special cli and extra build steps. But for us sqlite types, there's a much simpler way.

    Luckily, in my case, the sqlite schema database is a tiny file and can easily be distributed along with the library crate sources. But then you actually have to configure sqlx to find the damn thing, which, due to their reliance on .env files, is not as easy as you'd like it to be, especially in multi-package workspace environments. But thankfully cargo lets us have per-crate environmental config by just adding some instructions to build.rs.

    And presto! There you have it. Compile-time metadata that library consumers shouldn't even have to worry about, but need to anyway. Maybe this is something sqlx can improve in the future.

  32. So, #sqlx for #rust #RustLang is pretty great actually. Compile-time checked queries are a huge win for reliability! I love being able to check my queries at compile time while I'm developing. :blobcatheart: Huge benefit there!

    The trouble I've found so far with this approach is there's not a good way to turn it off when you don't need it!

    Downstream consumers of my library crates must compile from source (because ... Rust), but they really don't need to double-check my queries, because I already did it before I committed the code. It's just completely unnecessary for every library consumer to re-check the queries again for the same code.

    Tragically, sqlx still forces downstream consumers to check the queries anyway, and requires them to have all the query metadata necessary to do that. So as a library author, I need to do a bunch of extra work to enable that step, even tho it's reaaaaally not needed. :blobcatverysad:

    Yes, sqlx has an offline mode that is supposed to make this easier. And maybe it does for the postgres types. But it's actually pretty complicated to get that working since it requires a special cli and extra build steps. But for us sqlite types, there's a much simpler way.

    Luckily, in my case, the sqlite schema database is a tiny file and can easily be distributed along with the library crate sources. But then you actually have to configure sqlx to find the damn thing, which, due to their reliance on .env files, is not as easy as you'd like it to be, especially in multi-package workspace environments. But thankfully cargo lets us have per-crate environmental config by just adding some instructions to build.rs.

    And presto! There you have it. Compile-time metadata that library consumers shouldn't even have to worry about, but need to anyway. Maybe this is something sqlx can improve in the future.

  33. Released a new version of to use the new version of that fixes the following database security vulnerability:

    ⚠️ RUSTSEC-2024-0363
    rustsec.org/advisories/RUSTSEC

    Also replaced Askama with for the templates. The migration was trivial 😃

  34. Released a new version of #OxiTraffic to use the new version of #SQLx that fixes the following database security vulnerability:

    ⚠️ RUSTSEC-2024-0363
    rustsec.org/advisories/RUSTSEC

    Also replaced Askama with #Rinja for the templates. The migration was trivial 😃

  35. I used #sqlx for my #rust #database needs for the longest time but recently tried #diesel again which establishes and maintains a mapping between Rust types and tables for compile time checks.

    One nit I had to pick was that struct attributes couldn't easily represented as json/jsonb without manually implementing traits (sqlx has an attribute macro for that). diesel-json-derive (crates.io/crates/diesel-json-d) now allows for a similar experience with diesel.

  36. I used #sqlx for my #rust #database needs for the longest time but recently tried #diesel again which establishes and maintains a mapping between Rust types and tables for compile time checks.

    One nit I had to pick was that struct attributes couldn't easily represented as json/jsonb without manually implementing traits (sqlx has an attribute macro for that). diesel-json-derive (crates.io/crates/diesel-json-d) now allows for a similar experience with diesel.

  37. SQLx is such a nice crate!

    Recently I was stuck with some dynamic query building, which I didn’t knew about how to do it best in #sqlx I didn’t even knew what it’s called before I asked in Rust Lang Discord server.

    I got this in reply and I felt very dumb. I didn’t knew it was called “Dynamic Query Building”, I have to share code and scenario for it, but anyways

    stackoverflow.com/questions/74

    This post saved me for the day!

  38. I didn't touch #rustlang for couple of years. Decided to write an experimental web-API server using #Axum and #SQLX and it just works. That's so strange!

  39. I didn't touch #rustlang for couple of years. Decided to write an experimental web-API server using #Axum and #SQLX and it just works. That's so strange!

  40. Today i am stuggling with #SQLX migrations in #RustLang.
    I have an app, which starts with a sync main fn, which then continues in an async init fn.
    I have placed the migrate! macro there, but i am not able to migrate on `cargo build`. Anybody got a clue here?
    The documentation just says to run the macro when the application starts.
    Taggin @mo8it for being and sqlx-evangelist 😁️

  41. Today i am stuggling with #SQLX migrations in #RustLang.
    I have an app, which starts with a sync main fn, which then continues in an async init fn.
    I have placed the migrate! macro there, but i am not able to migrate on `cargo build`. Anybody got a clue here?
    The documentation just says to run the macro when the application starts.
    Taggin @mo8it for being and sqlx-evangelist 😁️

  42. @drakulix There isn't enough interest. I wouldn't pick a framework that doesn't allow me to scale to the maximum possible performance when needed. Because for me, Axum has pretty good UX already.

    I built multiple small to medium apps with #Axum and #SQLx and yes, getting into async involved some additional learning, but after that, the experience is very smooth.

  43. Yippee.. I seem to have got it working. Thanks to @briankung for encouragement.
    It seems this particular development directory got confused in some way that I don't understand.
    The same code (+ cargo.toml + db etc) worked in another project.
    So I started with a clean git clone, added the code & now it works.
    A bit scary that somewhere there is something I can't see that broke sqlx so thoroughly in this one directory.
    Still I have learned a lot about #RustLang testing, async & #sqlx which is good

  44. Spent hours struggling with #RustLang unit testing with #sqlx

    Using the #[sqlx:test] I can get my tests to work with sqlx::query but whenever I use the sqlx::query! macro the compiler can't find the db table.

  45. Elevate your Rust REST API development by seamlessly integrating SQLx, unraveling the simplicity and effectiveness of connecting to and managing databases.

    bocksdincoding.com/blog/connec

    #rust #rustlang #actixweb #rest #api #sqlx #db #sql #programming #tutorial

  46. Been doing a bit of reading for #PrayerOfHannah my #RustLang #SaaS project.
    Rather than using #Docker for deployment I'm wondering about compiling is as a #Wasm server app - technically I think #Wasix.
    Not a huge number of direct deployment hosts yet (but I think you can deploy fairly lightweight via docker).
    #Dbms support might be a limit at present (don't think #sqlx with #sqlite will be an option at the moment)

  47. As comfortable as I am with Rails and ActiveRecord,, I don't feel like ever learning another ORM again unless I'm forced to. SQL is fine. I can attribute this to years of working in #golang with #sqlx.

    I get the "limitations" but I wish more developers saw the benefits of working w/ straight SQL in their chosen framework. Maybe copilot/GPT makes it easier to do so.

    jmoiron.github.io/sqlx/