When to choose an ORM for your Database
ORMs, query builders and raw SQL each fit different situations, and many projects do best mixing them. ORMs offer generated types, migrations, database portability and framework conventions (Rails, Laravel, NestJS), while raw SQL avoids performance overhead, missing adapters, large serverless bundles and opaque generated queries. Query builders sit in between, giving more control than an ORM while still requiring SQL knowledge. Examples show Prisma's libSQL adapter, Drizzle with @libsql/client, and plain @libsql/client queries against Turso.
Related posts
- ORMs vs. Query Builders for your Typescript application
Neon mediumAdept
Drizzle, Kysely, Prisma and Zapatos are compared as type-safe Postgres libraries for TypeScript across schema definition, query syntax, raw SQL support, migrations, edge-runtime support and community size. Drizzle offers SQL-like syntax with drizzle-kit migration generation, Kysely favors WYSIWYG TypeScript-centric queries with hand-written up/down migrations, Zapatos generates types from the database but has no migrations, and Prisma uses its own schema language with Prisma Migrate. Performance differences were negligible in a small test (averages within 3ms). Prisma has by far the largest community, while the other three can run on edge runtimes via serverless Postgres drivers, which Prisma could not at the time.
- Build a Database App with Drizzle ORM and Deno
Deno mediumAdeptDrizzle ORM can be used from Deno via npm compatibility to get type-safe CRUD access to PostgreSQL. The walkthrough installs drizzle-orm, drizzle-kit and pg, configures drizzle.config.ts with a DATABASE_URL, and shows two schema paths: introspecting an existing database with `drizzle-kit pull` or defining pgTable schemas in TypeScript and generating migrations with `drizzle-kit generate`. It then builds helper functions for inserting, querying, updating and deleting rows across two related tables using a pg Pool-backed Drizzle client, with the Deno flags (--env, --node-modules-dir) needed to make drizzle-kit work.
- We're building Postgres in Rust. Using the LLVM of databases
Turso easyNoviceTurso, a Rust rewrite of SQLite, is adding a Postgres frontend by parsing Postgres SQL into a common AST and compiling it to Turso's VDBE bytecode, turning the engine into an "LLVM of databases" with pluggable frontends. The argument is that SQL databases differ mostly in on-disk layout, not in core operations, so Postgres semantics can be expressed in or added to the VDBE. A C-to-VDBE compiler running Doom illustrates that the bytecode works as a real VM. The work starts from the earlier pgmicro experiment and is early-stage but runnable from source. Planned pieces include the Postgres wire protocol, embedded and in-browser use, live materialized views, and WASM-sandboxed extensions, aiming for broad rather than 100% compatibility.
- pg_graphql v1.0
Supabase mediumAdeptpg_graphql, a PostgreSQL extension that compiles GraphQL requests into a single SQL query, reaches 1.0 with a SemVer backwards-compatibility guarantee. Running inside Postgres instead of as a separate server keeps its memory footprint negligible on 1 GB Free Plan instances. That design also gives it Postgres roles and RLS for security, an always-in-sync schema with no N+1 queries, and ACID rollback across multi-mutation requests. The original pure-SQL transpiler hit limits near 4,000 lines because SQL functions pass by value and the planner stops inlining deeply nested calls, so it was rewritten in Rust with pgx. After the rewrite, overhead is under 300µs per request, about 1,060 queries/sec per connection from SQL, and about 645 req/s through the full HTTP and auth stack on Free Plan hardware.
- Turso Adds Ruby on Rails Support
Turso mediumAdeptTurso has released a technical preview of libsql_activerecord, an ActiveRecord adapter that connects Rails applications to Turso/libSQL databases. Setup takes three steps: add the gem, set adapter: libsql with a database url and auth_token in config/database.yml, and optionally set a local path for an embedded replica that syncs the remote database to a local file to remove network latency and allow offline work. The adapter also works outside Rails, in standalone ActiveRecord scripts and Sinatra apps, and supports migrations, CRUD, associations and raw SQL.