https://github.com/feathers-studio/pg-extract
Extract schema from Postgres. A more complete fork of https://github.com/kristiandupont/extract-pg-schema.
https://github.com/feathers-studio/pg-extract
database postgres postgresql schema types
Last synced: 2 months ago
JSON representation
Extract schema from Postgres. A more complete fork of https://github.com/kristiandupont/extract-pg-schema.
- Host: GitHub
- URL: https://github.com/feathers-studio/pg-extract
- Owner: feathers-studio
- License: mit
- Created: 2025-03-24T06:03:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-18T15:18:36.000Z (about 1 year ago)
- Last Synced: 2025-04-19T04:43:42.254Z (about 1 year ago)
- Topics: database, postgres, postgresql, schema, types
- Language: TypeScript
- Homepage:
- Size: 9.02 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> [!WARNING]
> The relevant parts of this repo were rolled into https://github.com/feathers-studio/true-pg, which was the primary purpose of this project.
>
> This project is no longer maintained.
# Extract Schema from Postgres Database
Reads various metadata from your postgres database and return a Javascript object.
This package was originally forked from [extract-pg-schema](https://github.com/kristiandupont/extract-pg-schema) by [Kristian Dupont](https://github.com/kristiandupont) to extend its utility and to generate perfect types. It's now a standalone package.
> Note: This package is a work in progress and may have missing features or broken modules.
> However, it's already being used to generate types by [TruePG](https://github.com/feathers-studio/true-pg).
> You should probably use that instead.
## Installation
Choose your package manager:
```bash
bun add pg-extract
```
```bash
npm i pg-extract
```
```bash
pnpm add pg-extract
```
## Library Usage
You give it a [postgres connection config object](https://node-postgres.com/apis/client) and some options and it will connect to your database and generate an object with the schema.
```javascript
import { Extractor } from "pg-extract";
const extractor = new Extractor({
host: "localhost",
database: "postgres",
user: "postgres",
password: "postgres",
});
const result = await extractor.extractSchemas();
console.log(result);
```
---
## Contributors
We're grateful to [Kristian Dupont](https://github.com/kristiandupont) and the other contributors to the [extract-pg-schema](https://github.com/kristiandupont/extract-pg-schema) project for the package we are building on top of.