Я люблю 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 + аргументами на выходе.

https://habr.com/ru/articles/1042578/

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

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

Мне нравится чистый SQL. Не «нравится, потому что пришлось», а правда нравится. В хорошем SQL‑запросе обычно видно, что происходит с данными: откуда берём, как фильтруем,...

Хабр

Do i know any SQLX magicians?

We have an issue over at https://codeberg.org/Chfkch/bitritter/issues/59 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.

   

#SQLX #BitRitter #RustLang

Trouble building

Hi! I'm looking to try out Bitritter, but unfortunately v0.1.1 from the Alpine repos is unable to log into my Vaultwarden server. I tried building latest from source and, after installing all dependencies on my phone, ran into the following errors: ``` mat@hermes ~/D/bitritter (main)> cargo bui...

Codeberg.org

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.

https://sitr.us/2026/05/03/embedded-sql-highlighting-in-neovim/

Embedded SQL highlighting in Neovim, a look into Treesitter, and some NixOS patching

This is the story of the rabbit hole I went down because I wanted pretty syntax highlighting for embedded SQL queries in my Rust code. I’m a fan of sqlx, which provides macros for writing inline SQL with real-time type checking. Because the queries are in Rust strings the whole query is highlighted uniform green by default. That’s not acceptable! By the end of my journey I had highlighting looking like this: In most cases this kind of embedded syntax highlighting is easy in Neovim, and it’s often set up by default if you use the nvim-treesitter plugin. But I ran into some issues in this particular case. That led me to learn some things about Treesitter, and about how nixpkgs packages Neovim plugins, and Treesitter packages. If you care to follow along, you’ll hear a tale of Neovim, Treesitter, injection queries, patching, NixOS, and more patching!…

sitr.us

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

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

https://habr.com/ru/articles/1024854/

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

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

Всё началось с одного вопроса от старшего коллеги — что pgx предоставляет для сбора метрик. Казалось простым: открыл документацию, увидел QueryTracer, решил что вот оно — замена декоратору. Проверил...

Хабр

I really like using sqlx in rust. But wow I get many errors from rust-analyser when my database is offline. It always happens while doing some change, so I briefly think I've broken something mayor.

#rustlang #sqlx

@kubikpixel Yet another #database in #Rust, but neither #sqlx nor #diesel would support them.

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

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

TIL that the infamous N+1 queries problem does not apply to #SQLite. https://sqlite.org/np1queryprob.html

With other databases, it's a bad idea to, for example, look up 3 different configuration parameters by name using 3 queries. You need to batch them into a single query. That's because you have to wait for the database server to answer each query before sending the next one.

I wonder how this affects #Rust #sqlx, though. Running a query with sqlx does involve waiting on a worker thread…

#SQL #database

Many Small Queries Are Efficient In SQLite

#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