| 1 | --- |
| 2 | title: SQL |
| 3 | description: Choose a database, connect with Effect SQL, Drizzle, or Prisma ORM, and deploy committed migrations. |
| 4 | --- |
| 5 | |
| 6 | <span id="databases" /> |
| 7 | |
| 8 | ## Choose a database |
| 9 | |
| 10 | See [Databases](/sql/databases) to compare engines and connection paths, with links directly to each database's setup guide. |
| 11 | |
| 12 | <span id="clients" /> |
| 13 | <span id="effect-sql" /> |
| 14 | <span id="drizzle" /> |
| 15 | <span id="prisma-orm" /> |
| 16 | |
| 17 | ## Choose a client |
| 18 | |
| 19 | | Client | Guides | |
| 20 | | --- | --- | |
| 21 | | Effect SQL | [Postgres](/sql/effect-sql/postgres) · [MySQL](/sql/effect-sql/mysql) · [D1](/sql/effect-sql/d1) · [Durable Objects](/sql/effect-sql/migrations#durable-object-migrations) | |
| 22 | | Drizzle | [Postgres](/sql/drizzle/postgres) · [MySQL](/sql/drizzle/mysql) · [D1](/sql/drizzle/d1) · [Durable Objects](/sql/drizzle/migrations#durable-object-migrations) | |
| 23 | | Prisma ORM v8 | [Contracts](/sql/prisma/contracts) · [Postgres](/sql/prisma/postgres) · [Migrations](/sql/prisma/migrations) | |
| 24 | |
| 25 | Prisma ORM v8 requires PostgreSQL 17+ and is separate from the [Prisma hosting provider](/prisma). |
| 26 | |
| 27 | <span id="what-are-you-building" /> |
| 28 | |
| 29 | ## Find an integration |
| 30 | |
| 31 | | Integration | Guide | |
| 32 | | --- | --- | |
| 33 | | Lambda + Aurora PostgreSQL + Drizzle | [AWS](/aws/data/drizzle-aurora) | |
| 34 | | Lambda + Aurora DSQL + Drizzle | [AWS](/aws/data/drizzle-dsql) | |
| 35 | | Workers + Neon or PlanetScale + Drizzle | [Cloudflare](/cloudflare/data/drizzle) | |
| 36 | | Workers + D1 + Drizzle | [Cloudflare](/cloudflare/data/d1-drizzle) | |
| 37 | | Durable Objects + SQLite | [Cloudflare](/cloudflare/compute/durable-objects#sql-migrations) | |
| 38 | | Fly Service + Postgres + Drizzle | [Fly](/fly/data/drizzle-postgres) | |
| 39 | | Hetzner Service + external Postgres + Drizzle | [Hetzner](/hetzner/data/drizzle-postgres) | |
| 40 | | Prisma Compute + Postgres + Drizzle | [Prisma](/prisma/data/drizzle-postgres) | |
| 41 | | Railway Service + Postgres + Drizzle | [Railway](/railway/data/drizzle-postgres) | |
| 42 | | Railway Service + MySQL + Drizzle | [Railway](/railway/data/drizzle-mysql) | |
| 43 | | Workers + Neon + Prisma ORM | [Cloudflare](/cloudflare/data/prisma) | |
| 44 | |
| 45 | See [runnable examples](https://github.com/alchemy-run/alchemy/blob/main/examples/README.md) for complete projects. |
| 46 | |
| 47 | <span id="connection-lifecycle" /> |
| 48 | |
| 49 | ## Already have a database? |
| 50 | |
| 51 | ```typescript |
| 52 | import * as SQL from "alchemy/SQL/Postgres"; |
| 53 | import * as Config from "effect/Config"; |
| 54 | import * as Effect from "effect/Effect"; |
| 55 | |
| 56 | const query = Effect.gen(function* () { |
| 57 | const sql = yield* SQL.Postgres({ url: Config.Redacted("DATABASE_URL") }); |
| 58 | return yield* sql`SELECT 1 AS value`; |
| 59 | }); |
| 60 | ``` |
| 61 | |
| 62 | Run queries within the application's execution scope, or use `Effect.scoped` in a standalone program; see [connection lifecycle](/sql/effect-sql/lifecycle). |
| 63 | |
| 64 | <span id="where-next" /> |
| 65 | <span id="commit-migrations-before-deployment" /> |
| 66 | |
| 67 | ## Manage schema changes |
| 68 | |
| 69 | Generate migrations when schemas change, stage and review the schema, SQL, and snapshots with `git diff --cached`, then commit them before deployment. Apply the committed files using the selected database's workflow. |
| 70 | |
| 71 | [SQL files](/sql/effect-sql/migrations) · [Drizzle migrations](/sql/drizzle/migrations) · [Prisma migrations](/sql/prisma/migrations) |