You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@pgkit/schemainspect

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pgkit/schemainspect

SQL Schema Inspection for PostgreSQL

0.5.0
latest
Source
npmnpm
Version published
Weekly downloads
1.1K
-10.44%
Maintainers
1
Weekly downloads
 
Created
Source

schemainspect: SQL Schema Inspection for PostgreSQL

X (formerly Twitter) Follow

Inspects tables, views, materialized views, constraints, indexes, sequences, enums, functions, and extensions. Handles table partitioning and inheritance.

A port of @djrobstep's python schemainspect library.

Limitations: Function inspection only confirmed to work with SQL/PLPGSQL languages so far.

Basic Usage

Install with npm:

npm install @pgkit/schemainspect

Get an inspection object from an already opened SQLAlchemy session or connection as follows:

import {PostgreSQL} from '@pgkit/schemainspect'

const inspector = await PostgreSQL.create('postgresql://')

console.log(inspector.tables)
console.log(inspector.views)
console.log(inspector.functions)

console.log(inspector.tables[`"public"."mytable"`].schema)
console.log(inspector.tables[`"public"."mytable"`].name)
console.log(inspector.tables[`"public"."mytable"`].columns.mycolumn.dbtype)
console.log(inspector.tables[`"public"."mytable"`].columns.mycolumn.is_nullable)

The inspection object has attributes for tables, views, and all the other things it tracks. At each of these attributes you'll find a dictionary (Record<string, ...>) mapping from fully-qualified-and-quoted-name-of-thing-in-database to information object.

For instance, the information about a table books would be accessed as follows:

>>> books_table = i.tables['"public"."books"']
>>> books_table.name
'books'
>>> books_table.schema
'public'
>>> [each.name for each in books_table.columns]
['id', 'title', 'isbn']

Documentation

Documentation is a bit patchy at the moment. Watch this space!

Author Credits

Initial development, maintenance:

  • djrobstep

TypeScript port:

Contributions:

FAQs

Package last updated on 06 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts