Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ const prisma = new PrismaClient({ adapter });
export { prisma };
```

:::tip Using SQLite with Bun
When targeting Bun, use the `@prisma/adapter-libsql` adapter instead of `@prisma/adapter-better-sqlite3`. Bun doesn’t support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate Prisma Client like so:

```ts
import 'dotenv/config';
import { PrismaLibSql } from '@prisma/adapter-libsql';
import { PrismaClient } from '../generated/prisma/client';

const adapter = new PrismaLibSql({
url: process.env.DATABASE_URL ?? '',
});

const prisma = new PrismaClient({ adapter });

export { prisma };
```
:::

## 8. Write your first query

Create a `script.ts` file to test your setup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ const prisma = new PrismaClient({ adapter });
export { prisma };
```

:::tip Using SQLite with Bun
Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). When targeting Bun, use the `@prisma/adapter-libsql` adapter instead:

```ts
import 'dotenv/config';
import { PrismaLibSql } from '@prisma/adapter-libsql';
import { PrismaClient } from '../generated/prisma/client';

const adapter = new PrismaLibSql({
url: process.env.DATABASE_URL ?? '',
});

const prisma = new PrismaClient({ adapter });

export { prisma };
```

:::

## 8. Query your database

Now you can use Prisma Client to query your database. Create a `script.ts` file:
Expand Down
17 changes: 17 additions & 0 deletions content/200-orm/050-overview/500-databases/500-sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ const adapter = new PrismaBetterSqlite3({
const prisma = new PrismaClient({ adapter })
```

:::tip Using SQLite with Bun
When running Prisma Client on Bun, use the `@prisma/adapter-libsql` driver adapter. Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate the adapter and pass it to `PrismaClient`:

```ts
import { PrismaClient } from '../prisma/generated/client';
import { PrismaLibSql } from '@prisma/adapter-libsql';

const adapter = new PrismaLibSql({
url: process.env.DATABASE_URL ?? '',
});

const prisma = new PrismaClient({ adapter });

export default prisma;
```
:::
Comment on lines +69 to +84
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Clarify the import path for consistency.

The Bun tip looks good overall, but there's a subtle inconsistency that could confuse readers: the code example just above (line 61) imports from ./generated/prisma, while the new Bun tip imports from ../prisma/generated/client. These represent different project structures. Consider aligning them so readers understand they're illustrating different setups, or clarify which path applies to this database connector overview.

Consider updating line 73 to use ./generated/prisma to match the prior example, or add a brief note explaining why the paths differ:

-import { PrismaClient } from '../prisma/generated/client';
+import { PrismaClient } from './generated/prisma';

Alternatively, if the different path is intentional to show different project structures, a comment explaining this would help readers.


</script>

🏁 Script executed:

#!/bin/bash
# Retrieve the SQLite documentation file and examine the import paths around lines 61 and 73
cat content/200-orm/050-overview/500-databases/500-sqlite.mdx | head -90 | tail -40

Length of output: 1394


🏁 Script executed:

#!/bin/bash
# Get line numbers and context around the imports
sed -n '55,90p' content/200-orm/050-overview/500-databases/500-sqlite.mdx | cat -n

Length of output: 1586


🏁 Script executed:

#!/bin/bash
# Check if the file exists and get total line count
wc -l content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 61


🏁 Script executed:

#!/bin/bash
# Extract the exact lines 61 and 73 with context
echo "=== Around line 61 ===" && sed -n '58,65p' content/200-orm/050-overview/500-databases/500-sqlite.mdx
echo -e "\n=== Around line 73 ===" && sed -n '70,77p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 632


🏁 Script executed:

#!/bin/bash
# Search for all PrismaClient imports in the file to see the pattern
grep -n "from.*prisma" content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 617


🏁 Script executed:

#!/bin/bash
# Get more context around the Bun section to understand the structure
sed -n '65,85p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 547


🏁 Script executed:

#!/bin/bash
# Look for the entire file structure to understand sections
grep -n "^##\|^:::" content/200-orm/050-overview/500-databases/500-sqlite.mdx | head -20

Length of output: 508


🏁 Script executed:

#!/bin/bash
# Get the full context of both code examples
sed -n '50,90p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 1395


🏁 Script executed:

#!/bin/bash
# Verify the exact import statements with full context
rg -n "from.*generated.*prisma" content/200-orm/050-overview/500-databases/500-sqlite.mdx -C 3

Length of output: 446


🏁 Script executed:

#!/bin/bash
# Get the raw content to understand the structure precisely
head -90 content/200-orm/050-overview/500-databases/500-sqlite.mdx | tail -35

Length of output: 1276


🏁 Script executed:

#!/bin/bash
# Look for the Bun tip section specifically
sed -n '66,90p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 935


🏁 Script executed:

#!/bin/bash
# Extract lines 69-84 exactly as flagged in the review
sed -n '69,84p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 493


🏁 Script executed:

#!/bin/bash
# Get broader context: lines 55-85
sed -n '55,85p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 943


🏁 Script executed:

#!/bin/bash
# Look for "generated/prisma" pattern throughout the file
rg -n "generated.prisma|generated/client" content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 169


🏁 Script executed:

#!/bin/bash
# Find and display the immediate context before the Bun tip
sed -n '54,72p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 671


🏁 Script executed:

#!/bin/bash
# Comprehensive view of lines 50-90
awk 'NR>=50 && NR<=90' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 1395


🏁 Script executed:

#!/bin/bash
# Exactly what's in the snippet provided in the review
awk 'NR>=60 && NR<=85' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 741


🏁 Script executed:

#!/bin/bash
# Direct extract to validate the claim
sed -n '60,75p' content/200-orm/050-overview/500-databases/500-sqlite.mdx

Length of output: 583


🏁 Script executed:

#!/bin/bash
# Show all import statements in order
grep -n "^import " content/200-orm/050-overview/500-databases/500-sqlite.mdx | head -30

Length of output: 421


🏁 Script executed:

#!/bin/bash
# Check the file more carefully
sed -n '1,90p' content/200-orm/050-overview/500-databases/500-sqlite.mdx | tail -35

Length of output: 1276


🏁 Script executed:

#!/bin/bash
# Simple view
awk 'NR<=90' content/200-orm/050-overview/500-databases/500-sqlite.mdx | awk 'NR>=55'

Length of output: 1334


🏁 Script executed:

#!/bin/bash
# Final attempt - get file and look at it
head -85 content/200-orm/050-overview/500-databases/500-sqlite.mdx | tail -30

Length of output: 885


🏁 Script executed:

#!/bin/bash
# Check if file exists first
ls -la content/200-orm/050-overview/500-databases/500-sqlite.mdx 2>&1 || echo "File not found"
fd "500-sqlite" 2>/dev/null || find . -name "*sqlite*" -type f 2>/dev/null | head -10

Length of output: 164


🏁 Script executed:

#!/bin/bash
# Search for any sqlite related markdown files
find . -name "*sqlite*" -type f

Length of output: 257


🏁 Script executed:

#!/bin/bash
# Broader search
fd sqlite

Length of output: 249


🏁 Script executed:

#!/bin/bash
# Look in content directory
ls -la content/200-orm/050-overview/500-databases/ 2>&1 || ls -la content/ 2>&1 | head -20

Length of output: 1264


🏁 Script executed:

#!/bin/bash
# Try to find the file
rg -l sqlite content/ 2>/dev/null | head -5

Length of output: 257


🏁 Script executed:

#!/bin/bash
# Check directory structure
find content -type d | head -20

Length of output: 896


🏁 Script executed:

#!/bin/bash
# List markdown files in the expected location
find content -name "*.mdx" -o -name "*.md" 2>/dev/null | grep -i sqlite

Length of output: 214


🏁 Script executed:

#!/bin/bash
# General content directory listing
find content -maxdepth 4 -type f 2>/dev/null | grep 500-sqlite

Length of output: 57


🏁 Script executed:

#!/bin/bash
# Try a simpler approach
ls content/200-orm/050-overview/500-databases/ 2>&1 || echo "Path does not exist"
ls -la . | head -20

Length of output: 1515


🏁 Script executed:

#!/bin/bash
# Root directory check
pwd && ls -la | head -20

Length of output: 1234


🏁 Script executed:

#!/bin/bash
# Determine if this is a cloned repo and what's available
git status 2>&1 | head -5 || echo "Not a git repo"
find . -name "*.mdx" | head -10

Length of output: 865


🏁 Script executed:

#!/bin/bash
# Find any reference to sqlite in the codebase
rg -l "SQLite" . 2>/dev/null | head -5

Length of output: 268


🏁 Script executed:

#!/bin/bash
# Try to locate the specific file more directly
find . -path "*200-orm*" -name "*.mdx" 2>/dev/null

Length of output: 19476


🏁 Script executed:

#!/bin/bash
# Check if we're in the right directory
ls -la

Length of output: 1591


🏁 Script executed:

#!/bin/bash
# Final comprehensive check
find . -type f -name "*.mdx" 2>/dev/null | head -20

Length of output: 1623


🏁 Script executed:

#!/bin/bash
# Search for import statements with prisma/generated
rg "PrismaClient.*from.*generated" 2>/dev/null

Length of output: 24079


🏁 Script executed:

#!/bin/bash
# Look for the exact strings mentioned in the review
rg "\./generated/prisma|../prisma/generated/client" 2>/dev/null

Length of output: 38292


🏁 Script executed:

#!/bin/bash
# Try to see what repositories or files we can access
find . -maxdepth 3 -type f 2>/dev/null | head -30

Length of output: 762


🏁 Script executed:

#!/bin/bash
# Last attempt - direct file access
cat content/200-orm/050-overview/500-databases/500-sqlite.mdx 2>&1 | head -100

Length of output: 4054


Clarify the import paths between the driver adapter examples.

The inconsistency is real. Line 61's better-sqlite3 example imports from ./generated/prisma, but line 73's Bun tip imports from ../prisma/generated/client. While these may represent different project structures, adjacent code examples with divergent paths create confusion for readers trying to adapt the code to their own setup.

This is a valid minor issue worth resolving. Recommend either:

  1. Align the paths if both examples should follow the same default Prisma output convention (../generated/prisma), or
  2. Add a clarifying note above one or both examples explaining that the import path depends on where Prisma generates the client in your project structure.

The suggested fix to change line 73 to ./generated/prisma is reasonable if both examples target the same output location—verify that the Bun adapter example is intended to use the same project layout as the better-sqlite3 example before applying.

🤖 Prompt for AI Agents
In content/200-orm/050-overview/500-databases/500-sqlite.mdx around lines 69–84,
the Bun adapter example imports the Prisma client from
../prisma/generated/client while the better-sqlite3 example uses
./generated/prisma, causing confusion; update the Bun example to use the same
import path as the adjacent example (./generated/prisma) or add a brief note
above the examples stating that the import path varies by project layout and
should be adjusted to where the Prisma client is generated in the reader’s
project.


### 3. Configure timestamp format for backward compatibility

When using driver adapters with SQLite, you can configure how `DateTime` values are stored in the database using the `timestampFormat` option.
Expand Down
Loading