- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Open
Labels
frictionProduct sticking/ pain pointsProduct sticking/ pain points
Description
Validation/ Reproduction Steps
- Initialize a new TypeScript/ Node.js/ Drizzle project using the following instructions:
mkdir hello-drizzle
cd hello-drizzle
npm init -y
npm install typescript ts-node @types/node --save-dev
npx tsc --init
npm i drizzle-orm dotenv @libsql/client
npm i -D drizzle-kit
- 
In .env, setDATABASE_URLto your SQLite Cloud DB connection string.
- 
Create src/db/index.ts. Input the following code to connect Drizzle ORM to the database:
import { config } from 'dotenv';
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
config({ path: '.env' });
const client = createClient({
  url: process.env.DATABASE_URL!,
});
export const db = drizzle(client);
- Create drizzle.config.tsin the project root. Input the following code to configure Drizzle Kit with the database connection:
import { config } from 'dotenv';
import { defineConfig } from 'drizzle-kit';
config({ path: '.env ' });
export default defineConfig({
  schema: './src/db/schema.ts',
  dialect: 'sqlite',
  dbCredentials: {
    url: process.env.DATABASE_URL!, 
  },
});
- 
In package.json, include a new script:introspect": "drizzle-kit introspect. This command pulls DDL from an existing database and generates theschema.ts.
- 
npm run introspectthrowsLibsqlError: URL_PARAM_NOT_SUPPORTED: Unknown URL query parameter "apikey".
- 
Update drizzle.config.tswith the following code:
import { config } from 'dotenv';
import { defineConfig } from 'drizzle-kit';
config({ path: '.env ' });
export default defineConfig({
  schema: './src/db/schema.ts',
  out: './drizzle',
  dialect: 'sqlite',
  dbCredentials: {
    user: 'upasana-admin',
    password: process.env.DATABASE_PWD, // used admin user's password from the SQLite Cloud dashboard
    host: 'chtwalrwiz',
    port: 8860,
    database: 'chinook.sqlite',
  },
});
- npm run introspectthrows- Please provide required params: [x] url: undefined.
Notes
- Per this config doc, dbCredentials>SQLiteCredentials, theurlcan be a path to a local sqlite file. So Drizzle expects a SQLite DB connection string to point to a project DB file.
- Drizzle dialects: postgresql, mysql, sqlite.
 Drizzle allows 2 ways to setdbCredentials(see steps 4 and 7 above). For non-sqlite dialects, you can use either configuration. However, sqlite dialect only works withurl(see step 8 error message).
Related Issue(s)
sample content / JavaScript & Drizzle
Screenshots & Videos
N/A.
I'd attach my own project to this comment, but GitHub doesn't allow it. Happy to share over Slack.
Metadata
Metadata
Assignees
Labels
frictionProduct sticking/ pain pointsProduct sticking/ pain points