Documentation
¶
Overview ¶
Package watcher provides real-time, interactive database schema introspection and visualization for SQLite, PostgreSQL, and MySQL databases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶
func HTTPHandler(inspector Inspector) http.HandlerFunc
HTTPHandler returns an http.HandlerFunc that serves the schema watcher dashboard.
Behavior is polymorphic:
- Web browser / HTML view: Serves the interactive drag-and-drop dashboard.
- Machine / JSON view: Serves the raw schema payload when requested via the "?format=json" query parameter or an "Accept: application/json" header.
Types ¶
type Inspector ¶
type Inspector interface {
// Tables returns a list of all user-defined table names.
Tables(ctx context.Context) ([]string, error)
// Columns returns column descriptors for a table in "name|type|pk" format.
Columns(ctx context.Context, tableName string) ([]string, error)
// Relations returns foreign-key descriptors for a table in "fromCol -> targetTable.targetCol" format.
Relations(ctx context.Context, tableName string) ([]string, error)
}
Inspector defines the contract for database schema introspection. Implementations query database metadata catalog schemas to extract table structures, columns, and foreign key relationships.
func NewInspector ¶
NewInspector automatically detects the driver type of the provided *sql.DB connection and returns the corresponding Inspector implementation.
Supported drivers are:
- SQLite: CGO "*sqlite3.SQLiteDriver" (github.com/mattn/go-sqlite3) and pure Go "*sqlite.Driver" (modernc.org/sqlite)
- PostgreSQL: "*pq.Driver" (github.com/lib/pq) and "*stdlib.Driver" (github.com/jackc/pgx)
- MySQL / MariaDB: "*mysql.MySQLDriver" (github.com/go-sql-driver/mysql)
Returns an error if the database driver is unsupported.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
schema/mysql
Package mysql provides database schema introspection for MySQL and MariaDB databases.
|
Package mysql provides database schema introspection for MySQL and MariaDB databases. |
|
schema/postgres
Package postgres provides database schema introspection for PostgreSQL databases.
|
Package postgres provides database schema introspection for PostgreSQL databases. |
|
schema/sqlite
Package sqlite provides database schema introspection for SQLite databases.
|
Package sqlite provides database schema introspection for SQLite databases. |