adapter
Good day everyone, I am using nest.js with prisma in a docker environment but I haven't succeeded to seed my Database due to the following error in the attached inage.
could some give some help?

14 Replies
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the
#ask-ai channel awaits if you're curious!Hi @Lambertn33!
Are you using Accelerate connection string?
Starting with (prisma+postgres://) or are using a normal TCP connection string (starting with postgres:// or postgresql://)?
Could you share how you are instantiating Prisma Client?
Hello @Nurul (Prisma)
Thank you for your reply, I am using mysql/mariaDB adapter.
here is my prisma.config.ts:
import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
seed: 'tsx prisma/seed.ts',
},
datasource: {
url: env('DATABASE_URL'),
},
});
and my prisma file:
import { PrismaClient } from '@prisma/client';
import 'dotenv/config';
import { PrismaMariaDb } from '@prisma/adapter-mariadb';
const adapter = new PrismaMariaDb({
host: process.env.DB_HOST 'db',
port: parseInt(process.env.DB_PORT '3306', 10),
user: process.env.DB_USERNAME 'taskbid',
password: process.env.DB_PASSWORD 'taskbid',
database: process.env.DB_NAME || 'taskbid',
connectionLimit: 10,
});
const prisma = new PrismaClient({ adapter });
export default prisma;
and my schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
}
model User {
id String @id @default(uuid())
names String
email String @unique
password String
role Role @default(FREELANCER)
lastLogin DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
freelancer Freelancer?
@@map("users")
}
is there something that I am missing/doing wrong please?
I assume your MariaDB instance is running via docker?
Are you able to connect to it via an Database IDE?
Yes I am using docker,
I have been able to access my DB using the docker exec command.
With Prisma 7 it is recommended to use the prisma-client generator:
but that should not cause this issue.
@Nurul i updated as shown in the attached image, but also I got the diffrerent error

Did you run
npx prisma generate after changing generator to prisma-client?Yes
I did
Also your import seems to be wrong.
You are importing it like this:
import { PrismaClient } from '@prisma/client';
It should instead be from the output path you have generated.
import { PrismaClient } from '../generated/prisma/client'@Nurul after updating all these I came back to the initial problem
of Database connectivity,
the migration works but the seed keeps failing..
here is the seeding codes:
import bcrypt from 'bcryptjs';
import prisma from './prisma';
async function main() {
const password = await bcrypt.hash('password123', 10);
// Create Admin User
const adminUser = await prisma.user.create({
data: {
names: 'TaskBid Admin',
email: 'admin@taskbid.com',
password,
role: 'ADMIN',
},
include: {
freelancer: true,
},
});
// Create Freelancer User
const freelancerUser = await prisma.user.create({
data: {
names: 'Demo Freelancer',
email: 'freelancer@taskbid.com',
password,
role: 'FREELANCER',
},
include: {
freelancer: true,
},
});
console.log('Seeded data:', {
admin: adminUser.email,
freelancer: freelancerUser.email,
});
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});

Do you get the same error if you try to initialise Prisma Client like this:
Just pass the entire connection string via DATABASE_URL and check?
The issue is with connecting to the database for some reason
@Nurul it seems to work now.
I needed to review and make sure the docker-compose yml credentials mtach with the ,env credentials..
God bless you for your help..
I am glad to hear that the issue is resolved 🎉