sqlinspect

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sqlinspect provides reusable, read-only SQL catalog inspection.

Index

Constants

View Source
const (
	DefaultMaxRelations = 5000
	DefaultMaxColumns   = 50000
)

Variables

This section is empty.

Functions

func ListDatabases

func ListDatabases(ctx context.Context, db *sql.DB, driver string) ([]string, error)

ListDatabases returns databases accessible to the current connection user.

Types

type Catalog

type Catalog struct {
	Driver         string   `json:"driver"`
	Database       string   `json:"database,omitempty"`
	Databases      []string `json:"databases,omitempty"`
	DefaultSchema  string   `json:"defaultSchema,omitempty"`
	Schemas        []Schema `json:"schemas"`
	Truncated      bool     `json:"truncated,omitempty"`
	TruncateReason string   `json:"truncateReason,omitempty"`
}

func Inspect

func Inspect(ctx context.Context, db *sql.DB, driver string, limits Limits) (Catalog, error)

Inspect returns the current database's schemas, relations and columns using set-based catalog queries. It deliberately does not inspect other databases on the same server. Schemas are queried independently so empty schemas remain visible to callers.

type Column

type Column struct {
	Name     string `json:"name"`
	DataType string `json:"dataType,omitempty"`
	Ordinal  int    `json:"ordinal,omitempty"`
}

type Limits

type Limits struct {
	MaxRelations int
	MaxColumns   int
}

type Relation

type Relation struct {
	Name    string   `json:"name"`
	Type    string   `json:"type"`
	Columns []Column `json:"columns"`
}

type Schema

type Schema struct {
	Name      string     `json:"name"`
	Relations []Relation `json:"relations"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL