# pull (Prisma CLI v7) (/docs/cli/v7/db/pull) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Pull the state from the database to the Prisma schema using introspection Location: CLI > v7 > db > pull The `prisma db pull` command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema. ## Usage [#usage] ```bash prisma db pull [options] ``` The datasource URL configuration is read from the Prisma config file (e.g., `prisma.config.ts`). > [!WARNING] > This command will overwrite the current `schema.prisma` file with the new schema. Back up your current schema or commit to version control before running `db pull` if it contains important modifications. > [!NOTE] > Introspection with `db pull` on the [MongoDB connector](https://www.prisma.io/docs/orm/v7/core-concepts/supported-databases/mongodb) samples the data instead of reading a schema. ## Prerequisites [#prerequisites] Configure your database connection in `prisma.config.ts`: ```prisma file=schema.prisma generator client { provider = "prisma-client" output = "../generated/prisma" } datasource db { provider = "sqlite" } ``` ```typescript file=prisma.config.ts import { defineConfig, env } from "prisma/config"; export default defineConfig({ schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations", }, datasource: { url: env("DATABASE_URL"), }, }); ``` ## Flags [#flags] | Flag | Description | | -------------- | ---------------------------------------------- | | `-h`, `--help` | Display help message | | `--force` | Ignore current Prisma schema file | | `--print` | Print the introspected Prisma schema to stdout | ## Options [#options] | Option | Description | | ------------------------ | --------------------------------------------------------------------------------------------------------------------------- | | `--config` | Custom path to your Prisma config file | | `--schema` | Custom path to your Prisma schema | | `--url` | Override the datasource URL from the Prisma config file | | `--composite-type-depth` | Depth for introspecting composite types (e.g., MongoDB Embedded Documents). Default `-1` for infinite depth, `0` to disable | | `--schemas` | Specify database schemas to introspect (overrides datasource block) | | `--local-d1` | Generate a Prisma schema from a local Cloudflare D1 database | ## Examples [#examples] ### Introspect the database [#introspect-the-database] #### bun ```bash bunx prisma db pull ``` #### pnpm ```bash pnpm prisma db pull ``` #### yarn ```bash yarn prisma db pull ``` #### npm ```bash npx prisma db pull ``` Output: ```text Introspecting based on datasource defined in schema.prisma … ✔ Introspected 2 models and wrote them into schema.prisma in 38ms Run prisma generate to generate Prisma Client. ``` ### Specify a schema path [#specify-a-schema-path] #### bun ```bash bunx prisma db pull --schema=./alternative/schema.prisma ``` #### pnpm ```bash pnpm prisma db pull --schema=./alternative/schema.prisma ``` #### yarn ```bash yarn prisma db pull --schema=./alternative/schema.prisma ``` #### npm ```bash npx prisma db pull --schema=./alternative/schema.prisma ``` ### Print to stdout instead of writing to file [#print-to-stdout-instead-of-writing-to-file] #### bun ```bash bunx prisma db pull --print ``` #### pnpm ```bash pnpm prisma db pull --print ``` #### yarn ```bash yarn prisma db pull --print ``` #### npm ```bash npx prisma db pull --print ``` ### Force overwrite existing schema [#force-overwrite-existing-schema] Ignore any customizations in the current schema: #### bun ```bash bunx prisma db pull --force ``` #### pnpm ```bash pnpm prisma db pull --force ``` #### yarn ```bash yarn prisma db pull --force ``` #### npm ```bash npx prisma db pull --force ``` ### Set composite type depth for MongoDB [#set-composite-type-depth-for-mongodb] #### bun ```bash bunx prisma db pull --composite-type-depth=2 ``` #### pnpm ```bash pnpm prisma db pull --composite-type-depth=2 ``` #### yarn ```bash yarn prisma db pull --composite-type-depth=2 ``` #### npm ```bash npx prisma db pull --composite-type-depth=2 ``` ## Related pages - [`execute`](https://www.prisma.io/docs/cli/v7/db/execute): Execute native commands to your database - [`push`](https://www.prisma.io/docs/cli/v7/db/push): Push the state from your Prisma schema to your database - [`seed`](https://www.prisma.io/docs/cli/v7/db/seed): Seed your database with test or initial data using custom scripts