You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@pgkit/schemainspect

Package Overview
Dependencies
Maintainers
0
Versions
46
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


Version published
Weekly downloads
17
decreased by-88.74%
Maintainers
0
Created
Weekly downloads
 

Readme

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 12 Jul 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc