
Prisma Client Api Raw Queries
- 14 installs
- 8 repo stars
- Updated February 9, 2026
- prisma/cursor-plugin
prisma-client-api-raw-queries runs parameterized raw SQL via Prisma Client.
About
The prisma-client-api-raw-queries skill covers $queryRaw and $executeRaw tagged templates returning rows or affected counts. Prisma.sql and Prisma.join build dynamic safe fragments while Prisma.raw handles identifiers only. Unsafe variants warn about injection when concatenating user strings. Database-specific PostgreSQL array and JSON operators and MySQL full-text examples appear. Transactions wrap raw balance transfers on tx clients. BigInt COUNT results need Number conversion. Guidance contrasts safe parameterized templates against unsafe string interpolation. Use when ORM queries cannot express required SQL while keeping user input parameterized. $queryRaw returns typed SELECT result rows. $executeRaw reports INSERT UPDATE DELETE counts. Prisma.sql and Prisma.join compose safe dynamic SQL. Documents unsafe variants and injection risks. Shows raw SQL inside interactive transactions. Parameterized raw queries without SQL injection exposure. User writes $queryRaw or $executeRaw with dynamic fragments. Developers needing SQL features beyond Prisma query API.
- $queryRaw returns typed SELECT result rows.
- $executeRaw reports INSERT UPDATE DELETE counts.
- Prisma.sql and Prisma.join compose safe dynamic SQL.
- Documents unsafe variants and injection risks.
- Shows raw SQL inside interactive transactions.
Prisma Client Api Raw Queries by the numbers
- 14 all-time installs (skills.sh)
- Ranked #604 of 911 Databases skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
prisma-client-api-raw-queries capabilities & compatibility
- Capabilities
- safe versus unsafe raw query patterns · prisma.join dynamic conditions · bigint and date result handling
- Use cases
- database · api development
What prisma-client-api-raw-queries says it does
User input is parameterized
SQL injection vulnerability
npx skills add https://github.com/prisma/cursor-plugin --skill prisma-client-api-raw-queriesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 14 |
|---|---|
| repo stars | ★ 8 |
| Last updated | February 9, 2026 |
| Repository | prisma/cursor-plugin ↗ |
How do I run raw SQL safely in Prisma?
Run typed raw SQL with $queryRaw and $executeRaw while avoiding injection via parameterized templates.
Who is it for?
Developers needing SQL features beyond Prisma query API.
Skip if: Skip when typed model queries cover the use case.
When should I use this skill?
User writes $queryRaw or $executeRaw with dynamic fragments.
What you get
Parameterized raw queries without SQL injection exposure.
Files
Raw Queries
Execute raw SQL when Prisma's query API isn't sufficient.
$queryRaw
Execute SELECT queries and get typed results:
const users = await prisma.$queryRaw`
SELECT * FROM "User" WHERE email LIKE ${'%@prisma.io'}
`With type
type User = { id: number; email: string; name: string | null }
const users = await prisma.$queryRaw<User[]>`
SELECT id, email, name FROM "User" WHERE role = ${'ADMIN'}
`Dynamic table/column names
Use Prisma.raw() for identifiers (not safe for user input):
import { Prisma } from '../generated/client'
const column = 'email'
const users = await prisma.$queryRaw`
SELECT ${Prisma.raw(column)} FROM "User"
`With Prisma.sql
Build queries dynamically:
import { Prisma } from '../generated/client'
const email = 'alice@prisma.io'
const query = Prisma.sql`SELECT * FROM "User" WHERE email = ${email}`
const users = await prisma.$queryRaw(query)Join multiple SQL fragments
import { Prisma } from '../generated/client'
const conditions = [
Prisma.sql`role = ${'ADMIN'}`,
Prisma.sql`verified = ${true}`
]
const users = await prisma.$queryRaw`
SELECT * FROM "User"
WHERE ${Prisma.join(conditions, ' AND ')}
`$executeRaw
Execute INSERT, UPDATE, DELETE (returns affected count):
const count = await prisma.$executeRaw`
UPDATE "User" SET verified = true WHERE email LIKE ${'%@prisma.io'}
`
console.log(`Updated ${count} users`)Delete example
const deleted = await prisma.$executeRaw`
DELETE FROM "User" WHERE "deletedAt" < ${thirtyDaysAgo}
`Insert example
const inserted = await prisma.$executeRaw`
INSERT INTO "Log" (message, level, timestamp)
VALUES (${message}, ${level}, ${new Date()})
`$queryRawUnsafe / $executeRawUnsafe
For fully dynamic queries (use with caution!):
// ⚠️ SQL injection risk - only use with trusted input
const table = 'User'
const users = await prisma.$queryRawUnsafe(
`SELECT * FROM "${table}" WHERE id = $1`,
userId
)Parameterized unsafe query
const result = await prisma.$executeRawUnsafe(
'UPDATE "User" SET name = $1 WHERE id = $2',
'Alice',
1
)SQL Injection Prevention
Safe (parameterized)
// ✅ User input is parameterized
const email = userInput
const users = await prisma.$queryRaw`
SELECT * FROM "User" WHERE email = ${email}
`Unsafe (concatenation)
// ❌ SQL injection vulnerability!
const email = userInput
const users = await prisma.$queryRawUnsafe(
`SELECT * FROM "User" WHERE email = '${email}'`
)Database-Specific Features
PostgreSQL
// Array operations
const users = await prisma.$queryRaw`
SELECT * FROM "User" WHERE 'admin' = ANY(roles)
`
// JSON operations
const users = await prisma.$queryRaw`
SELECT * FROM "User" WHERE metadata->>'theme' = 'dark'
`MySQL
// Full-text search
const posts = await prisma.$queryRaw`
SELECT * FROM Post WHERE MATCH(title, content) AGAINST(${searchTerm})
`Transactions with Raw Queries
await prisma.$transaction(async (tx) => {
await tx.$executeRaw`UPDATE "Account" SET balance = balance - ${amount} WHERE id = ${senderId}`
await tx.$executeRaw`UPDATE "Account" SET balance = balance + ${amount} WHERE id = ${recipientId}`
})Handling Results
BigInt handling
PostgreSQL returns BigInt for COUNT:
const result = await prisma.$queryRaw<[{ count: bigint }]>`
SELECT COUNT(*) as count FROM "User"
`
const count = Number(result[0].count)Date handling
type Result = { createdAt: Date }
const users = await prisma.$queryRaw<Result[]>`
SELECT "createdAt" FROM "User"
`
// createdAt is already a Date object{
"name": "prisma-client-api-raw-queries",
"version": "7.0.0",
"author": "prisma",
"license": "MIT"
}Related skills
FAQ
What does prisma-client-api-raw-queries do?
prisma-client-api-raw-queries runs parameterized raw SQL via Prisma Client.
When should I use prisma-client-api-raw-queries?
User writes $queryRaw or $executeRaw with dynamic fragments.
Is this skill safe to install?
Review the Security Audits panel on this page before installing in production.