SQL · template

Give your agent your PostgreSQL schema, without a login

One file in. Tables, types and foreign keys that an assistant can use.

Import a PostgreSQL schema file. Then your assistant knows the tables, types and foreign keys, can say what a change touches, and can write GraphQL, Protobuf, Avro or JSON Schema types.

What you get

Your assistant gets the tables, columns, types and foreign keys of a PostgreSQL database from one file. It can then tell you which tables a change touches, and write typed code for them. It never gets a login and never sees a row.

What we didWhat CoreModels answeredTime
Imported the schema file21 tables, 86 columns, 1 list of allowed values6 s
Asked what points to the table film3 tables: film_actor, film_category, inventory1 s
Asked for GraphQL types of film2 types with required fields and the allowed values1 s

Recorded on 4 December 2026 with the Sakila sample database for PostgreSQL, a film rental shop kept by the jOOQ team (repository). Licence: BSD. We also loaded this example into PostgreSQL 17 and read the file that pg_dump 17 wrote: the same 21 tables and 86 columns.

What you need

  • A CoreModels account with one project. Every plan starts with a 14-day free trial; a card is required to start.
  • An assistant that can use MCP servers, for example Claude Code or Cursor.
  • No PostgreSQL login. CoreModels reads a file with CREATE TABLE statements.

Run it

1. Connect your assistant

In Claude Code, run this command. Then sign in when it asks. This address can write to your projects, because an import creates a model.

claude mcp add --transport http coremodels https://go.coremodels.io/mcp-admin

Cursor, Claude Desktop and other clients: connect guide.

2. Import the schema

The example is a public file, so you can run it as it is.

Create a CoreModels project named "PostgreSQL example". Then call import_schema on it with format "sql" and this customFileUrl:
https://raw.githubusercontent.com/jOOQ/sakila/38c2e4ef53cf7ef2eec873d42c5a1e2c7afa0231/postgres-sakila-db/postgres-sakila-schema.sql

Your assistant calls create_project, then import_schema. The answer we got:

import_schema (part of the answer)

{
  "succeeded": true,
  "format": "sql",
  "decoded": {
    "types": 21,
    "elements": 86,
    "taxonomies": 1,
    "listItems": 5
  },
  "written": {
    "types": 21,
    "elements": 86,
    "taxonomies": 1,
    "listItems": 5
  }
}

decoded is what the file has. written is what is in your project now. The two are equal, so nothing was lost between them. The full answer also lists what the model does not hold, for example indexes and default values.

3. Ask before you change a table

A foreign key points from another table to this one. In a large database that is easy to miss.

Call analyze_concept_impact for "film" in this project. Which tables point to it, and with which column?

Your assistant calls analyze_concept_impact. The answer we got:

analyze_concept_impact (part of the answer)

{
  "label": "film",
  "kind": "Type",
  "governedUsage": [
    {
      "kind": "referencedByElement",
      "description": "Referenced by element 'film_id' on type 'film_actor'."
    },
    {
      "kind": "referencedByElement",
      "description": "Referenced by element 'film_id' on type 'inventory'."
    },
    {
      "kind": "referencedByElement",
      "description": "Referenced by element 'film_id' on type 'film_category'."
    }
  ]
}

This call only reads. The full answer also lists the columns of the table.

4. Get types for your code

The model writes other formats from the same tables. This is GraphQL.

Call export_schema with format "graphql" for the type film only.

Your assistant calls export_schema. The answer we got:

export_schema (the content)

scalar DateTime

type film {
  rating: mpaa_rating
  length: Int
  special_features: [String]
  description: String
  replacement_cost: Float!
  original_language_id: language
  release_year: String
  last_update: DateTime!
  title: String!
  language_id: language!
  rental_rate: Float!
  rental_duration: Int!
  film_id: Int!
}

type language {
  name: String!
  language_id: Int!
  last_update: DateTime!
}

enum mpaa_rating {
  G
  PG
  PG_13
  R
  NC_17
}

Other formats are JSON Schema, Protobuf, Avro, LinkML, OWL and a data contract (ODCS).

Now with your own project

Run this where you can reach the database. The file has no rows in it. Then give your assistant the prompt.

pg_dump --schema-only --no-owner --no-privileges "$DATABASE_URL" > schema.sql
Create a CoreModels project for our database. Import schema.sql with import_schema, format "sql". Show me decoded and written, and the list of what was not kept. Then tell me which tables point to YOUR_TABLE.

What it does not do

  • Indexes, default values, triggers, views and functions are not kept. The answer names each one.
  • The length of a text column and the mark for a primary key are named in the answer and not kept in the model.
  • Your assistant sends your own file as text. With a very large schema, send the tables you need. pg_dump -t film -t language writes only the tables you name.
  • The pass or fail check of our connectors does not cover a SQL file. After a change, import the new file again.
  • CoreModels does not connect to your PostgreSQL server.

← Back to SQL

Start building

14-day free trial. Builder $49/mo after the trial. Cancel any time.