How to insert data into a table in a postgresql database using prisma?

Viewed 14

My question will be brief. I use prisma to manage my postgresql database. I would like to insert objects into a table in my database from my prisma file. So I inserted the following code:

INSERT INTO "User" ("firstName","email","password") VALUES ("Stephie","goune3@gmail.com","affaires")

this gave me the following error:

Error: Get config: Schema Parsing P1012

error: Error validating: This line is invalid. It does not start with any known Prisma schema keyword.
  -->  schema.prisma:57
   | 
56 | 
57 | INSERT INTO "User" ("firstName","email","password") VALUES ("Stephie","goune3@gmail.com","affaires")
58 | 
   | 

Validation Error Count: 1

So I replaced the double quotes with the single quotes, but it still gave me the same error. I can't find much about it on the internet.

1 Answers

You're probably using Prisma wrong way, schema file is only for defining database model, it can't execute raw SQL statement. If you want to insert initial data to table, use seeding feature.

Related