Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kgajera/prisma-client-cli

Generates a CLI from your Prisma schema that allows you to query, seed, and export data
https://github.com/kgajera/prisma-client-cli

Last synced: 21 days ago
JSON representation

Generates a CLI from your Prisma schema that allows you to query, seed, and export data

Awesome Lists containing this project

README

        

# Prisma Client CLI

[![npm](https://img.shields.io/npm/v/prisma-client-cli)](https://www.npmjs.com/package/prisma-client-cli)
[![CI](https://github.com/kgajera/prisma-client-cli/actions/workflows/CI.yml/badge.svg)](https://github.com/kgajera/prisma-client-cli/actions/workflows/CI.yml)

A Prisma [generator](https://www.prisma.io/docs/concepts/components/prisma-schema/generators) that generates a command-line interface from your Prisma schema using [oclif](https://oclif.io). Use the CLI to run queries, seed records, or export your query results to a CSV file.

View the [example project](/example) to see it in action.

## Getting Started

1. Install the generator and oclif:

```
npm install prisma-client-cli @oclif/core --save-dev
```

1. Add the generator to your Prisma schema:

```prisma
generator cli {
provider = "prisma-client-cli"
}
```

1. Run Prisma's [`generate`](https://www.prisma.io/docs/reference/api-reference/command-reference#generate) command to generate the CLI in the `./prisma/cli/` directory:

```
npx prisma generate
```

1. Add the following configuration for oclif to your `package.json`:
```json
"oclif": {
"commands": "./prisma/cli/commands",
"topicSeparator": " "
}
```
For more information about oclif's configuration, refer to their [documentation](https://oclif.io).

## 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_CLIENT_CLI=false
```