Axat
Axat
Explore posts from servers
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
Thanks for the help.
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
const config: ConnectionOptions = {
host: process.env.DB_HOST!,
user: process.env.DB_USERNAME!,
password: process.env.DB_PASSWORD!,
database: process.env.DB_NAME!,
};
const connection = await mysql.createConnection(config);
const config: ConnectionOptions = {
host: process.env.DB_HOST!,
user: process.env.DB_USERNAME!,
password: process.env.DB_PASSWORD!,
database: process.env.DB_NAME!,
};
const connection = await mysql.createConnection(config);
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
yes just figured it out, added database field in ConnectionOptions
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
Able to resolve it, I had to do pnpm i again at the root, and start the project again. now I am getting this error
>>> tRPC Request from expo-react by undefined
>>> tRPC Error on 'post.all' Error: No database selected
at PromiseConnection.query (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mysql2/promise.js:82:26)
... 2 lines matching cause stack trace ...
at QueryPromise.then (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/query-promise.js:28:21) {
code: 'INTERNAL_SERVER_ERROR',
name: 'TRPCError',
[cause]: Error: No database selected
at PromiseConnection.query (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mysql2/promise.js:82:26)
at MySql2PreparedQuery.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/mysql2/session.js:58:37)
at QueryPromise.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/mysql-core/query-builders/query.js:100:31)
at QueryPromise.then (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/query-promise.js:28:21) {
code: 'ER_NO_DB_ERROR',
errno: 1046,
sql: 'select `id`, `name`, `content`, `created_at`, `updatedAt` from `t3turbo_post` `post` order by `post`.`id` desc
limit 10',
sqlState: '3D000',
sqlMessage: 'No database selected'
}
}
>>> tRPC Request from expo-react by undefined
>>> tRPC Error on 'post.all' Error: No database selected
at PromiseConnection.query (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mysql2/promise.js:82:26)
... 2 lines matching cause stack trace ...
at QueryPromise.then (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/query-promise.js:28:21) {
code: 'INTERNAL_SERVER_ERROR',
name: 'TRPCError',
[cause]: Error: No database selected
at PromiseConnection.query (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]/node_modules/mysql2/promise.js:82:26)
at MySql2PreparedQuery.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/mysql2/session.js:58:37)
at QueryPromise.execute (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/mysql-core/query-builders/query.js:100:31)
at QueryPromise.then (webpack-internal:///(rsc)/../../node_modules/.pnpm/[email protected]_@[email protected]/node_modules/drizzle-orm/query-promise.js:28:21) {
code: 'ER_NO_DB_ERROR',
errno: 1046,
sql: 'select `id`, `name`, `content`, `created_at`, `updatedAt` from `t3turbo_post` `post` order by `post`.`id` desc
limit 10',
sqlState: '3D000',
sqlMessage: 'No database selected'
}
}
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
Full stacktrace:
○ Compiling /api/trpc/[trpc] ...
⨯ ../../packages/db/src/index.ts:2:0
Module not found: Can't resolve 'mysql2/promise'
1 | import { drizzle } from "drizzle-orm/mysql2";
> 2 | import mysql, { ConnectionOptions } from "mysql2/promise";
3 |
4 | import * as auth from "./schema/auth";
5 | import * as post from "./schema/post";

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
../../packages/auth/src/index.ts
./src/app/api/trpc/[trpc]/route.ts
../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=D%3A%5Cdevelopment%5Cakashdevcc%5Cspartan-solar%5Csparta%5Capps%5Cnextjs%5Csrc%5Capp%5Capi%5Ctrpc%5C%5Btrpc%5D%5Croute.ts
○ Compiling /api/trpc/[trpc] ...
⨯ ../../packages/db/src/index.ts:2:0
Module not found: Can't resolve 'mysql2/promise'
1 | import { drizzle } from "drizzle-orm/mysql2";
> 2 | import mysql, { ConnectionOptions } from "mysql2/promise";
3 |
4 | import * as auth from "./schema/auth";
5 | import * as post from "./schema/post";

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
../../packages/auth/src/index.ts
./src/app/api/trpc/[trpc]/route.ts
../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js?absolutePagePath=D%3A%5Cdevelopment%5Cakashdevcc%5Cspartan-solar%5Csparta%5Capps%5Cnextjs%5Csrc%5Capp%5Capi%5Ctrpc%5C%5Btrpc%5D%5Croute.ts
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
I did that for my db package That error is gone now, But getting new error now:
Module not found: Can't resolve 'mysql2/promise'
Module not found: Can't resolve 'mysql2/promise'
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
@Angelelz
13 replies
DTDrizzle Team
Created by Axat on 1/29/2024 in #help
Getting error while using Drizzle with MySQL2
I am not sure, I am just using the t3-turbo stack, and it's using nextjs it should be smart-enough to figure out that it should run on server side, no?
13 replies