Prisma CLI Generator

A Prisma generator that generates a command-line interface from your Prisma schema using oclif. Use the CLI to run queries, seed records, or export your query results to a CSV file.
View the example project to see it in action.
Getting Started
-
Install the generator and oclif:
npm install prisma-generator-cli @oclif/core --save-dev
-
Add the generator to your Prisma schema:
generator cli {
provider = "prisma-generator-cli"
}
-
Run Prisma's generate command to generate the CLI in the ./prisma/cli/ directory:
npx prisma generate
-
Add the following configuration for oclif to your package.json:
"oclif": {
"commands": "./prisma/cli/commands",
"topicSeparator": " "
}
For more information about oclif's configuration, refer to their documentation.
CLI Usage
Run ./prisma/cli/bin/run --help to view available commands for your generated CLI.
Exporting to CSV
Use the --_csv flag to output the query results as comma-separated values.
Disable Generator
You can prevent the CLI from being generated by setting the following environment variable:
PRISMA_GENERATOR_CLI=false