dbexplorer

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("operación no soportada por este motor")

ErrUnsupported is returned by Driver/KVDriver methods for operations that don't map onto a given engine (e.g. CreateSchema on MySQL, where schema IS the database) instead of faking a behavior the engine doesn't have.

Functions

func AssetsFS

func AssetsFS() (fs.FS, error)

AssetsFS returns the built frontend (frontend/dist) as an fs.FS rooted at the dist directory, for serving via http.FileServer.

func IsKVEngine

func IsKVEngine(normalizedType string) bool

IsKVEngine reports whether a normalized engine name is key-value (Redis) rather than relational — the frontend uses App.GetFeatures-style info to decide whether to render the table tree or the key browser.

func LoadCreds

func LoadCreds() map[string]Cred

LoadCreds loads all saved DB credentials from disk.

func NormalizeDbType

func NormalizeDbType(t string) string

NormalizeDbType maps a free-form database type string to a registered driver name (see RegisterDriver in driver.go).

func RegisterDriver

func RegisterDriver(name string, factory NetDriverFactory)

RegisterDriver registers a network-based engine under a normalized name (see NormalizeDbType). Called from each driver file's init().

func RegisterKVDriver

func RegisterKVDriver(name string, factory KVDriverFactory)

RegisterKVDriver registers a key-value engine under a normalized name. Called from each KV driver file's init().

func RenderIndexHTML

func RenderIndexHTML(sessionID, dbType, portStr, remotePath, apiBase string) ([]byte, error)

RenderIndexHTML reads the built index.html and injects session/dbType/ port/path/apiBase into its #navoro-config script tag, replacing the previous PLACEHOLDER_* string-substitution mechanism now that the frontend is a Vite build (hashed asset filenames can't be substituted directly). Standalone mode calls this with all-empty strings, leaving `{}` in place.

func SaveCreds

func SaveCreds(m map[string]Cred)

SaveCreds persists all DB credentials to disk.

Types

type Capabilities

type Capabilities struct {
	CreateDatabase bool `json:"createDatabase"`
	DropDatabase   bool `json:"dropDatabase"`
	CreateSchema   bool `json:"createSchema"`
	DropSchema     bool `json:"dropSchema"`
	CreateTable    bool `json:"createTable"`
	DropTable      bool `json:"dropTable"`
	Backup         bool `json:"backup"`
	Restore        bool `json:"restore"`

	// Explain/Stats/Sessions/Users are computed by Manager.Capabilities via
	// type-assertion against the optional interfaces in
	// core/observability.go — no adapter sets these fields itself.
	Explain  bool `json:"explain"`
	Stats    bool `json:"stats"`
	Sessions bool `json:"sessions"`
	Users    bool `json:"users"`
}

Capabilities declares which DDL/backup operations a connected engine supports, so the frontend can show only the operations that make sense for the engine currently in use instead of offering something that would always fail or that would have to be faked with a workaround.

type CassandraDriver

type CassandraDriver struct {
	// contains filtered or unexported fields
}

CassandraDriver implements Driver for Cassandra/ScyllaDB. Keyspaces are Cassandra's "databases"; there's no separate schema level (a keyspace already contains tables directly), so ListSchemas returns a single value and the sidebar collapses it, same as MySQL. Cassandra has no foreign key constraints, so GetForeignKeys always returns an empty slice.

func (*CassandraDriver) BackupTable

func (d *CassandraDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*CassandraDriver) Capabilities

func (d *CassandraDriver) Capabilities() Capabilities

func (*CassandraDriver) Close

func (d *CassandraDriver) Close() error

func (*CassandraDriver) CreateDatabase

func (d *CassandraDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase creates a keyspace. SimpleStrategy with replication_factor 1 is a reasonable single-node/dev default — it is NOT meant for production multi-datacenter clusters, which should use NetworkTopologyStrategy with per-DC replication factors instead.

func (*CassandraDriver) CreateSchema

func (d *CassandraDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: a keyspace already is the "schema" level here (see ListSchemas above), nothing separate to create.

func (*CassandraDriver) CreateTable

func (d *CassandraDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*CassandraDriver) CreateUser

func (d *CassandraDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via CREATE ROLE ... WITH PASSWORD AND LOGIN = true.

func (*CassandraDriver) DropDatabase

func (d *CassandraDriver) DropDatabase(ctx context.Context, name string) error

func (*CassandraDriver) DropSchema

func (d *CassandraDriver) DropSchema(ctx context.Context, database, schema string) error

func (*CassandraDriver) DropTable

func (d *CassandraDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*CassandraDriver) DropUser

func (d *CassandraDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DROP ROLE.

func (*CassandraDriver) Explain

func (d *CassandraDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer. CQL has no text EXPLAIN/query-plan facility comparable to SQL engines — the closest analog is enabling tracing (query.Trace(...)) on the query, actually running it, and reading back the recorded steps from system_traces.events. analyze is ignored: tracing only ever works against a real execution, there's no "static plan without running it" variant to switch to.

func (*CassandraDriver) GetColumns

func (d *CassandraDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*CassandraDriver) GetForeignKeys

func (d *CassandraDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*CassandraDriver) GetIndexes

func (d *CassandraDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*CassandraDriver) GrantPrivilege

func (d *CassandraDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager (schema is ignored — a keyspace already is the schema level here, see ListSchemas above).

func (*CassandraDriver) ListDatabases

func (d *CassandraDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*CassandraDriver) ListSchemas

func (d *CassandraDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*CassandraDriver) ListTables

func (d *CassandraDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*CassandraDriver) ListUsers

func (d *CassandraDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via system_auth.roles (Cassandra's own user concept when role-based auth is enabled on the cluster).

func (*CassandraDriver) Query

func (d *CassandraDriver) Query(ctx context.Context, database, query string) QueryResult

func (*CassandraDriver) RevokePrivilege

func (d *CassandraDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*CassandraDriver) Stats

func (d *CassandraDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider with minimal cluster-topology metrics — cluster-wide resource metrics (heap, throughput, ...) live in JMX, not in anything queryable via CQL, so this stays to what system.local/ system.peers can report.

type ClickHouseDriver

type ClickHouseDriver struct {
	// contains filtered or unexported fields
}

ClickHouseDriver implements Driver for ClickHouse. ClickHouse has no separate schema level (a "database" already is the unit tables live in), so ListSchemas returns a single value and the sidebar collapses it — same as MySQL. It also has no foreign key constraints at all, so GetForeignKeys always returns an empty slice.

func (*ClickHouseDriver) BackupTable

func (d *ClickHouseDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*ClickHouseDriver) Capabilities

func (d *ClickHouseDriver) Capabilities() Capabilities

func (*ClickHouseDriver) Close

func (d *ClickHouseDriver) Close() error

func (*ClickHouseDriver) CreateDatabase

func (d *ClickHouseDriver) CreateDatabase(ctx context.Context, name string) error

func (*ClickHouseDriver) CreateSchema

func (d *ClickHouseDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: ClickHouse has no schema level separate from the database (see ListSchemas above).

func (*ClickHouseDriver) CreateTable

func (d *ClickHouseDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*ClickHouseDriver) CreateUser

func (d *ClickHouseDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager.

func (*ClickHouseDriver) DropDatabase

func (d *ClickHouseDriver) DropDatabase(ctx context.Context, name string) error

func (*ClickHouseDriver) DropSchema

func (d *ClickHouseDriver) DropSchema(ctx context.Context, database, schema string) error

func (*ClickHouseDriver) DropTable

func (d *ClickHouseDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*ClickHouseDriver) DropUser

func (d *ClickHouseDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager.

func (*ClickHouseDriver) Explain

func (d *ClickHouseDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer via plain EXPLAIN. ClickHouse also has EXPLAIN PIPELINE/EXPLAIN ESTIMATE/EXPLAIN AST variants, but plain EXPLAIN (the query plan) is the generally useful default; analyze is ignored and always produces the same plain plan rather than guessing which of the alternate EXPLAIN kinds the caller actually wants.

func (*ClickHouseDriver) GetColumns

func (d *ClickHouseDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*ClickHouseDriver) GetForeignKeys

func (d *ClickHouseDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*ClickHouseDriver) GetIndexes

func (d *ClickHouseDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*ClickHouseDriver) GrantPrivilege

func (d *ClickHouseDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager (schema is ignored — ClickHouse has no schema level separate from the database, see ListSchemas above).

func (*ClickHouseDriver) KillSession

func (d *ClickHouseDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via KILL QUERY WHERE query_id = ...

func (*ClickHouseDriver) ListDatabases

func (d *ClickHouseDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*ClickHouseDriver) ListSchemas

func (d *ClickHouseDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*ClickHouseDriver) ListSessions

func (d *ClickHouseDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via system.processes.

func (*ClickHouseDriver) ListTables

func (d *ClickHouseDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*ClickHouseDriver) ListUsers

func (d *ClickHouseDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via system.users.

func (*ClickHouseDriver) Query

func (d *ClickHouseDriver) Query(ctx context.Context, database, query string) QueryResult

func (*ClickHouseDriver) RevokePrivilege

func (d *ClickHouseDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*ClickHouseDriver) Stats

Stats implements StatsProvider via system.metrics/system.asynchronous_metrics plus total on-disk size across system.parts.

type ColumnDef

type ColumnDef struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Nullable   bool   `json:"nullable"`
	PrimaryKey bool   `json:"primaryKey"`
	Default    string `json:"default"`
}

ColumnDef describes one column of a table to be created via CreateTable.

type ConnParams

type ConnParams struct {
	Host     string
	Port     int
	User     string
	Password string
	// Database is only required by engines with a single fixed
	// database/service per connection instead of a browsable list (Oracle:
	// service name: Firebird: database file path). Ignored by engines that
	// list databases dynamically (Postgres/MySQL/SQL Server/ClickHouse).
	Database string
	Dial     DialFunc // nil = direct net.Dial
}

ConnParams are the network-driver connection parameters. File-based engines (SQLite) don't go through this — see ConnectSQLite/ConnectLocalSQLite.

type Cred

type Cred struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

Cred holds saved credentials for a given db type/port combination.

type DbConn

type DbConn struct {
	ID        string
	SessionID string
	DbType    string
	// contains filtered or unexported fields
}

DbConn holds an active database connection. It's engine-agnostic (all query logic lives behind driver, see driver.go) aside from a couple of SQLite-remote-file bookkeeping fields, which are a transport concern (SFTP sync) unrelated to SQL access and deliberately kept out of Driver.

type DialFunc

type DialFunc func(network, addr string) (net.Conn, error)

DialFunc opens a raw TCP connection to addr. A nil DialFunc means "dial directly" (net.Dial); a non-nil one is typically an SSH tunnel (ssh.Client.Dial), but drivers never need to know which — that's the whole point of this abstraction.

type Driver

type Driver interface {
	ListDatabases(ctx context.Context) ([]string, error)
	ListSchemas(ctx context.Context, database string) ([]string, error)
	ListTables(ctx context.Context, database, schema string) ([]string, error)
	GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)
	GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)
	GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)
	Query(ctx context.Context, database, query string) QueryResult
	Close() error

	// CreateDatabase/DropDatabase/CreateSchema/DropSchema/CreateTable/
	// DropTable/BackupTable back the DDL/backup surface (core/ddl.go). Each
	// returns ErrUnsupported when the engine has no equivalent concept
	// (e.g. CreateSchema on MySQL, where schema IS the database) instead of
	// simulating a behavior the engine doesn't actually have. Capabilities
	// reports which of these are implemented so the frontend can show only
	// what applies to the connected engine.
	CreateDatabase(ctx context.Context, name string) error
	DropDatabase(ctx context.Context, name string) error
	CreateSchema(ctx context.Context, database, schema string) error
	DropSchema(ctx context.Context, database, schema string) error
	CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error
	DropTable(ctx context.Context, database, schema, table string) error
	BackupTable(ctx context.Context, database, schema, table string) (string, error)
	Capabilities() Capabilities
}

Driver is the interface each database engine implements once (postgres.go, mysql.go, sqlite.go, ...). Adding a new engine (Oracle, SQL Server, ...) means writing one new file that implements this interface and registers itself in init() — nothing else in this package changes.

type ElasticsearchDriver

type ElasticsearchDriver struct {
	// contains filtered or unexported fields
}

ElasticsearchDriver implements KVDriver. An index is Elasticsearch's "database"; a document ID is the "key". Unlike Redis there's no cheap SCAN — ListKeys runs a _search (match_all, or a wildcard query on _id when pattern is set) bounded to 500 hits, which is a real query, not an instant listing.

func (*ElasticsearchDriver) BackupDatabase

func (d *ElasticsearchDriver) BackupDatabase(ctx context.Context, database string) (string, error)

BackupDatabase exports every document in the index as NDJSON, reusing ListKeys' bounded (500-hit) _search and GetValue's per-document JSON body.

func (*ElasticsearchDriver) Capabilities

func (d *ElasticsearchDriver) Capabilities() Capabilities

func (*ElasticsearchDriver) Close

func (d *ElasticsearchDriver) Close() error

func (*ElasticsearchDriver) CreateContainer

func (d *ElasticsearchDriver) CreateContainer(ctx context.Context, database, container string) error

CreateContainer/DropContainer are unsupported: in this mapping an index is the "database" and a document is the "key" — there's no grouping level in between.

func (*ElasticsearchDriver) CreateDatabase

func (d *ElasticsearchDriver) CreateDatabase(ctx context.Context, name string) error

func (*ElasticsearchDriver) CreateUser

func (d *ElasticsearchDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via PUT /_security/user/{username}, created with no roles yet (an empty roles array is valid) — roles are attached afterward via GrantPrivilege.

func (*ElasticsearchDriver) DeleteKey

func (d *ElasticsearchDriver) DeleteKey(ctx context.Context, database, key string) error

func (*ElasticsearchDriver) DropContainer

func (d *ElasticsearchDriver) DropContainer(ctx context.Context, database, container string) error

func (*ElasticsearchDriver) DropDatabase

func (d *ElasticsearchDriver) DropDatabase(ctx context.Context, name string) error

func (*ElasticsearchDriver) DropUser

func (d *ElasticsearchDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DELETE /_security/user/{username}.

func (*ElasticsearchDriver) GetValue

func (d *ElasticsearchDriver) GetValue(ctx context.Context, database, key string) (KVValue, error)

func (*ElasticsearchDriver) GrantPrivilege

func (d *ElasticsearchDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager. Elasticsearch security is role-based (a role bundles its own privilege definitions) rather than a single ad hoc "grant this one thing" call, so `privilege` here is reinterpreted AS a role name: this reads the user's current roles array, adds privilege if not already present, and PUTs the whole user document back — there's no endpoint to add one role to a user in place. database/schema/table are ignored: ES role privileges are defined on the role itself (via a separate role definition), not per grant call.

func (*ElasticsearchDriver) KillSession

func (d *ElasticsearchDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via POST /_tasks/{id}/_cancel. id is the "node:task_id" form ListSessions reports — only cancellable tasks can actually be cancelled, ES's own response reflects that rather than this method pre-filtering.

func (*ElasticsearchDriver) ListDatabases

func (d *ElasticsearchDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*ElasticsearchDriver) ListKeys

func (d *ElasticsearchDriver) ListKeys(ctx context.Context, database, pattern string) ([]string, error)

func (*ElasticsearchDriver) ListSessions

func (d *ElasticsearchDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via _tasks, listing in-flight search/index tasks across every node (not scoped to one index) — the closest analog Elasticsearch has to "sessions".

func (*ElasticsearchDriver) ListUsers

func (d *ElasticsearchDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via the Security API's GET /_security/user. This endpoint (and the rest of this interface's methods) only works on licensed/security-enabled clusters — on a cluster without security enabled, ES itself returns an error (403/"security not enabled") which is surfaced to the caller as-is rather than pre-detected here.

func (*ElasticsearchDriver) RevokePrivilege

func (d *ElasticsearchDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager — see GrantPrivilege for the role-array read-modify-write this mirrors, removing privilege instead of adding it.

func (*ElasticsearchDriver) SetValue

func (d *ElasticsearchDriver) SetValue(ctx context.Context, database, key, value string) error

func (*ElasticsearchDriver) Stats

Stats implements StatsProvider via _cluster/stats — cluster-wide, since Stats itself takes no index/database argument.

type EngineStats

type EngineStats struct {
	Metrics []StatMetric `json:"metrics"`
}

EngineStats is a snapshot of engine-reported resource/activity metrics. The frontend polls StatsProvider.Stats repeatedly and keeps its own rolling history per Label to chart trends — engines only ever need to report the current instantaneous reading.

type Explainer

type Explainer interface {
	Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)
}

Explainer runs a query through the engine's own query-plan facility (EXPLAIN, EXPLAIN ANALYZE, PROFILE, ...) instead of actually executing it for its result set. analyze requests the "really run it and report actual timings" variant where the engine supports one; implementations without that distinction may ignore it.

type FirebirdDriver

type FirebirdDriver struct {
	// contains filtered or unexported fields
}

FirebirdDriver implements Driver for Firebird. Like Oracle, one connection is scoped to a single database file (ConnParams.Database) — there's no cross-database catalog to browse, and Firebird has no schema concept either, so ListDatabases/ListSchemas both just echo back the fixed value, same pattern as SQLite.

Note: firebirdsql has no public custom-dialer hook, so SSH-tunneled connections aren't supported for Firebird yet — only ConnectDirect.

func (*FirebirdDriver) BackupTable

func (d *FirebirdDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*FirebirdDriver) Capabilities

func (d *FirebirdDriver) Capabilities() Capabilities

func (*FirebirdDriver) Close

func (d *FirebirdDriver) Close() error

func (*FirebirdDriver) CreateDatabase

func (d *FirebirdDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase/DropDatabase are unsupported: a connection is scoped to a single fixed database file (ConnParams.Database, see ListDatabases above).

func (*FirebirdDriver) CreateSchema

func (d *FirebirdDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: Firebird has no schema concept (see ListSchemas above, which always returns the fixed "main").

func (*FirebirdDriver) CreateTable

func (d *FirebirdDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*FirebirdDriver) CreateUser

func (d *FirebirdDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager (Firebird 3+).

func (*FirebirdDriver) DropDatabase

func (d *FirebirdDriver) DropDatabase(ctx context.Context, name string) error

func (*FirebirdDriver) DropSchema

func (d *FirebirdDriver) DropSchema(ctx context.Context, database, schema string) error

func (*FirebirdDriver) DropTable

func (d *FirebirdDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*FirebirdDriver) DropUser

func (d *FirebirdDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager (Firebird 3+).

func (*FirebirdDriver) GetColumns

func (d *FirebirdDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*FirebirdDriver) GetForeignKeys

func (d *FirebirdDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*FirebirdDriver) GetIndexes

func (d *FirebirdDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*FirebirdDriver) GrantPrivilege

func (d *FirebirdDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager (database/schema are ignored — a Firebird connection is scoped to one fixed database file with no schema level, see ListDatabases/ListSchemas above; table is the only scope that varies here, with an empty table meaning a database-wide grant).

func (*FirebirdDriver) ListDatabases

func (d *FirebirdDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*FirebirdDriver) ListSchemas

func (d *FirebirdDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*FirebirdDriver) ListTables

func (d *FirebirdDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*FirebirdDriver) ListUsers

func (d *FirebirdDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via SEC$USERS (Firebird 3+ only — older Firebird has no SQL-visible user table at all).

func (*FirebirdDriver) Query

func (d *FirebirdDriver) Query(ctx context.Context, database, query string) QueryResult

func (*FirebirdDriver) RevokePrivilege

func (d *FirebirdDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

type ForeignKey

type ForeignKey struct {
	Name      string `json:"name"`
	Column    string `json:"column"`
	RefTable  string `json:"refTable"`
	RefColumn string `json:"refColumn"`
}

ForeignKey describes a single foreign key column, returned by GetForeignKeys.

type GrantInfo

type GrantInfo struct {
	Database  string `json:"database"`
	Schema    string `json:"schema"`
	Table     string `json:"table"`
	Privilege string `json:"privilege"`
}

GrantInfo is one privilege a user currently holds, as reported by PrivilegeLister — Schema/Table are "" when the privilege was found at a coarser level (a whole database) rather than a specific schema/table.

type GraphData

type GraphData struct {
	Nodes []GraphNode `json:"nodes"`
	Edges []GraphEdge `json:"edges"`
}

GraphData is a deduplicated node-link view extracted from a query result, for engines that return graph-shaped data (see QueryResult.Graph).

type GraphEdge

type GraphEdge struct {
	ID    string         `json:"id"`
	Type  string         `json:"type"`
	From  string         `json:"from"`
	To    string         `json:"to"`
	Props map[string]any `json:"props"`
}

GraphEdge is a single relationship in a GraphData result.

type GraphNode

type GraphNode struct {
	ID     string         `json:"id"`
	Labels []string       `json:"labels"`
	Props  map[string]any `json:"props"`
}

GraphNode is a single node in a GraphData result.

type Index

type Index struct {
	Name    string   `json:"name"`
	Columns []string `json:"columns"`
	Unique  bool     `json:"unique"`
}

Index describes a single index on a table, returned by GetIndexes.

type InfluxDB2Driver

type InfluxDB2Driver struct {
	// contains filtered or unexported fields
}

InfluxDB2Driver implements Driver for InfluxDB 2.x. Unlike InfluxDB 3.x (SQL, see influxdb3.go), 2.x only speaks Flux — a functional query language, not SQL. Its Query method therefore expects Flux text, not SQL; the frontend has no per-engine language switch, it's just a plain text editor either way. "Organization" (ConnParams.Database) scopes every call; buckets stand in for "databases", and measurements (found via the influxdata/influxdb/schema Flux package) stand in for "tables".

func (*InfluxDB2Driver) BackupTable

func (d *InfluxDB2Driver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

BackupTable is not implemented: this app's Restore model replays a backup as a script of statements through the generic Query method, but InfluxDB2 only understands Flux (a query/read language) — there is no Flux "statement" that inserts a single row of line-protocol data, and driving arbitrary line-protocol writes through the Query text box would be a different, incompatible restore mechanism. Rather than fake a backup format Restore can't actually replay, we report this engine as non-backupable/restorable via Capabilities.

func (*InfluxDB2Driver) Capabilities

func (d *InfluxDB2Driver) Capabilities() Capabilities

func (*InfluxDB2Driver) Close

func (d *InfluxDB2Driver) Close() error

func (*InfluxDB2Driver) CreateDatabase

func (d *InfluxDB2Driver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase creates a bucket (InfluxDB2's "database") in the fixed organization this connection is scoped to.

func (*InfluxDB2Driver) CreateSchema

func (d *InfluxDB2Driver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema: schema is the fixed constant "default" for this engine, there's nothing to create or drop.

func (*InfluxDB2Driver) CreateTable

func (d *InfluxDB2Driver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

CreateTable/DropTable: measurements have no DDL in InfluxDB — they appear implicitly the first time a point is written to them, and there is no "drop this measurement" API distinct from deleting its data.

func (*InfluxDB2Driver) CreateUser

func (d *InfluxDB2Driver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager. InfluxDB2 API access is token-based, not password-based (see AuthorizationsAPI/GrantPrivilege below) — but the server does separately support username/password sign-in (used by its own UI/CLI), so when a password is supplied here we set it on the new user via UpdateUserPasswordWithID rather than silently discarding it; an empty password just creates the bare user record.

func (*InfluxDB2Driver) DropDatabase

func (d *InfluxDB2Driver) DropDatabase(ctx context.Context, name string) error

DropDatabase deletes a bucket by name.

func (*InfluxDB2Driver) DropSchema

func (d *InfluxDB2Driver) DropSchema(ctx context.Context, database, schema string) error

func (*InfluxDB2Driver) DropTable

func (d *InfluxDB2Driver) DropTable(ctx context.Context, database, schema, table string) error

func (*InfluxDB2Driver) DropUser

func (d *InfluxDB2Driver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager.

func (*InfluxDB2Driver) GetColumns

func (d *InfluxDB2Driver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*InfluxDB2Driver) GetForeignKeys

func (d *InfluxDB2Driver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*InfluxDB2Driver) GetIndexes

func (d *InfluxDB2Driver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*InfluxDB2Driver) GrantPrivilege

func (d *InfluxDB2Driver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager by creating a new API token (Authorization) scoped to the given bucket ("database") and owned by username, with read/write actions derived from privilege. schema/table are ignored: InfluxDB2 permissions are bucket-granular, it has no concept of a schema or table beneath that.

func (*InfluxDB2Driver) ListDatabases

func (d *InfluxDB2Driver) ListDatabases(ctx context.Context) ([]string, error)

func (*InfluxDB2Driver) ListSchemas

func (d *InfluxDB2Driver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*InfluxDB2Driver) ListTables

func (d *InfluxDB2Driver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*InfluxDB2Driver) ListUsers

func (d *InfluxDB2Driver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via the Users API. InfluxDB2 has no per-user "superuser" flag or role list the way Postgres does — its access model is organization membership plus token permissions — so Roles/ Superuser are left at their zero value here.

func (*InfluxDB2Driver) Query

func (d *InfluxDB2Driver) Query(ctx context.Context, database, flux string) QueryResult

func (*InfluxDB2Driver) RevokePrivilege

func (d *InfluxDB2Driver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager: since InfluxDB2 privileges live on per-token Authorizations rather than being attached directly to a user, "revoke" here deletes every one of username's existing authorizations that is scoped solely to this bucket — the counterpart of the tokens GrantPrivilege creates. privilege itself isn't consulted: a bucket-scoped token grants exactly the actions it was created with, there's no partial "read but not write" token to narrow.

func (*InfluxDB2Driver) Stats

func (d *InfluxDB2Driver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider using the two lightweight endpoints the existing client already wraps: Ready (server uptime, via "started") and Health (overall server status). This is a much smaller surface than the admin/monitoring APIs InfluxDB Cloud exposes, but it's what a stock InfluxDB2 OSS deployment actually offers without extra setup.

type InfluxDB3Driver

type InfluxDB3Driver struct {
	// contains filtered or unexported fields
}

InfluxDB3Driver implements Driver for InfluxDB 3.x, which (unlike 1.x/ 2.x) supports real SQL over HTTP (built on Apache DataFusion), so it fits the standard relational Driver shape directly — no separate query language handling needed. ConnParams.Password carries the API token (InfluxDB3 auth is token-based, not user/password); ConnParams.Database, if set, is used as the default database.

Note: reached over plain HTTP request/response, so ConnParams.Dial (SSH tunneling) is honored via a custom http.Transport dialer.

func (*InfluxDB3Driver) BackupTable

func (d *InfluxDB3Driver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

BackupTable: unlike InfluxDB2, InfluxDB3 does speak real SQL over HTTP (DataFusion), so SELECT * + rendering INSERT statements the way postgres.go does would parse fine — but InfluxDB3 has no SQL INSERT/write endpoint at all (writes only happen via the separate /api/v2/write line-protocol ingest API), so a script of "INSERT INTO ... VALUES ..." replayed through Query would fail on every statement. Rather than produce a backup Restore can't actually replay, report this engine as non-backupable.

func (*InfluxDB3Driver) Capabilities

func (d *InfluxDB3Driver) Capabilities() Capabilities

func (*InfluxDB3Driver) Close

func (d *InfluxDB3Driver) Close() error

func (*InfluxDB3Driver) CreateDatabase

func (d *InfluxDB3Driver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase creates a database via the InfluxDB3 configure API.

func (*InfluxDB3Driver) CreateSchema

func (d *InfluxDB3Driver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema: schema is fixed to "iox" for this engine.

func (*InfluxDB3Driver) CreateTable

func (d *InfluxDB3Driver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

CreateTable/DropTable: like InfluxDB2, InfluxDB3 tables (measurements) have no DDL — they're created implicitly on first write via the line-protocol ingest API, not through SQL.

func (*InfluxDB3Driver) DropDatabase

func (d *InfluxDB3Driver) DropDatabase(ctx context.Context, name string) error

DropDatabase deletes a database via the InfluxDB3 configure API.

func (*InfluxDB3Driver) DropSchema

func (d *InfluxDB3Driver) DropSchema(ctx context.Context, database, schema string) error

func (*InfluxDB3Driver) DropTable

func (d *InfluxDB3Driver) DropTable(ctx context.Context, database, schema, table string) error

func (*InfluxDB3Driver) Explain

func (d *InfluxDB3Driver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer. InfluxDB3's SQL layer (Apache DataFusion) supports real EXPLAIN/EXPLAIN ANALYZE, so this reuses the exact same SQL-over-HTTP path as Query — no separate plan-format handling needed.

func (*InfluxDB3Driver) GetColumns

func (d *InfluxDB3Driver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*InfluxDB3Driver) GetForeignKeys

func (d *InfluxDB3Driver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*InfluxDB3Driver) GetIndexes

func (d *InfluxDB3Driver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*InfluxDB3Driver) ListDatabases

func (d *InfluxDB3Driver) ListDatabases(ctx context.Context) ([]string, error)

func (*InfluxDB3Driver) ListSchemas

func (d *InfluxDB3Driver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*InfluxDB3Driver) ListTables

func (d *InfluxDB3Driver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*InfluxDB3Driver) Query

func (d *InfluxDB3Driver) Query(ctx context.Context, database, query string) QueryResult

func (*InfluxDB3Driver) Stats

func (d *InfluxDB3Driver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider. /health reports basic server liveness; /metrics (Prometheus exposition format, exposed by both InfluxDB3 Core and Enterprise) is scanned for a couple of standard Go-runtime gauges to give a sense of process uptime/memory without needing a real admin API.

type KVBackupEntry

type KVBackupEntry struct {
	Key   string `json:"key"`
	Value string `json:"value"`
	Type  string `json:"type,omitempty"`
}

KVBackupEntry is one exported key, in the NDJSON format BackupDatabase implementations write and KVRestore reads back — one JSON object per line, in the same shape KVValue already uses for a single key's value.

type KVConn

type KVConn struct {
	ID        string
	SessionID string
	DbType    string
	// contains filtered or unexported fields
}

KVConn holds an active key-value connection (Redis today).

type KVDriver

type KVDriver interface {
	ListDatabases(ctx context.Context) ([]string, error)
	ListKeys(ctx context.Context, database, pattern string) ([]string, error)
	GetValue(ctx context.Context, database, key string) (KVValue, error)
	SetValue(ctx context.Context, database, key, value string) error
	DeleteKey(ctx context.Context, database, key string) error
	Close() error

	// CreateDatabase/DropDatabase/CreateContainer/DropContainer/
	// BackupDatabase mirror Driver's DDL/backup surface (core/ddl.go) for
	// key-value engines. "Container" is the engine's own grouping unit one
	// level under "database" where it has one (Mongo: collection); engines
	// without such a level (Redis, Elasticsearch) return ErrUnsupported.
	// Capabilities reports which operations are actually implemented.
	CreateDatabase(ctx context.Context, name string) error
	DropDatabase(ctx context.Context, name string) error
	CreateContainer(ctx context.Context, database, container string) error
	DropContainer(ctx context.Context, database, container string) error
	BackupDatabase(ctx context.Context, database string) (string, error)
	Capabilities() Capabilities
}

KVDriver is the interface non-relational, key-value-style engines implement — a parallel track to Driver (see driver.go) for engines where "connection → databases → schemas → tables → columns" doesn't apply. Redis is the first implementation (redis.go); Mongo/Elasticsearch/ Cassandra/Neo4j can follow the same shape later, reinterpreting "key" as their own primary browsing unit (document ID, row key, node ID, ...).

type KVDriverFactory

type KVDriverFactory func(ctx context.Context, id string, params ConnParams) (KVDriver, error)

KVDriverFactory constructs and connects a KVDriver, verifying connectivity before returning.

type KVValue

type KVValue struct {
	Type  string `json:"type"`  // "string" | "list" | "hash" | "set" | "zset"
	TTL   int64  `json:"ttl"`   // seconds until expiry, -1 = no expiry, -2 = key doesn't exist
	Value string `json:"value"` // raw string for "string"; JSON-encoded array/object otherwise
}

KVValue is a single key's value, normalized across Redis' data types (and future KVDriver implementations) for the frontend's key browser.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager tracks active database connections across all engines — both relational (conns, driven by Driver) and key-value (kvConns, driven by KVDriver; see kvdriver.go/kvapi.go).

func NewManager

func NewManager() *Manager

NewManager creates an empty connection manager.

func (*Manager) Backup

func (m *Manager) Backup(connID, database, schema, table, scope string) (string, error)

Backup generates a restorable script for a table, an entire schema (every table in it), or an entire database (every schema and table in it), depending on scope ("table" | "schema" | "database").

func (*Manager) Capabilities

func (m *Manager) Capabilities(connID string) (Capabilities, error)

Capabilities reports which DDL/backup operations the connection's engine supports — works for both relational (Driver) and key-value (KVDriver) connections, whichever connID resolves to.

func (*Manager) Connect

func (m *Manager) Connect(client *ssh.Client, sessionID, dbType string, port int, user, password, database string) (string, error)

Connect opens an SSH-tunneled database connection using native Go drivers. database is only meaningful for engines with a single fixed database/service per connection (Oracle's service name, Firebird's database path) — see ConnParams.Database; other engines ignore it.

func (*Manager) ConnectDirect

func (m *Manager) ConnectDirect(sessionID, dbType, host string, port int, user, password, database string) (string, error)

ConnectDirect opens a connection straight to host:port, with no SSH tunnel involved — for navoro standalone's "no SSH" connections. database is only meaningful for engines with a single fixed database/service per connection (see ConnParams.Database).

func (*Manager) ConnectKV

func (m *Manager) ConnectKV(client *ssh.Client, sessionID, dbType string, port int, user, password string) (string, error)

ConnectKV opens an SSH-tunneled key-value connection (Redis).

func (*Manager) ConnectKVDirect

func (m *Manager) ConnectKVDirect(sessionID, dbType, host string, port int, user, password string) (string, error)

ConnectKVDirect opens a key-value connection straight to host:port, no SSH tunnel — for navoro standalone's "no SSH" connections.

func (*Manager) ConnectLocalSQLite

func (m *Manager) ConnectLocalSQLite(sessionID, path string) (string, error)

ConnectLocalSQLite opens a local SQLite file directly (no SFTP), for navoro standalone's "SQLite / Local" connections.

func (*Manager) ConnectSQLite

func (m *Manager) ConnectSQLite(client *sftp.Client, sessionID, remotePath string) (string, error)

ConnectSQLite downloads a remote SQLite database to a private temporary file over SFTP and opens it.

func (*Manager) CreateDatabase

func (m *Manager) CreateDatabase(connID, name string) error

CreateDatabase creates a new database on the given connection.

func (*Manager) CreateSchema

func (m *Manager) CreateSchema(connID, database, schema string) error

CreateSchema creates a new schema inside a database.

func (*Manager) CreateTable

func (m *Manager) CreateTable(connID, database, schema, table string, columns []ColumnDef) error

CreateTable creates a new table (database → schema → table).

func (*Manager) CreateUser

func (m *Manager) CreateUser(connID, username, password string) error

CreateUser creates a database-engine-level user account.

func (*Manager) Disconnect

func (m *Manager) Disconnect(connID string)

Disconnect closes the driver and cleans up any transport resources.

func (*Manager) DropDatabase

func (m *Manager) DropDatabase(connID, name string) error

DropDatabase drops a database on the given connection.

func (*Manager) DropSchema

func (m *Manager) DropSchema(connID, database, schema string) error

DropSchema drops a schema inside a database.

func (*Manager) DropTable

func (m *Manager) DropTable(connID, database, schema, table string) error

DropTable drops a table.

func (*Manager) DropUser

func (m *Manager) DropUser(connID, username string) error

DropUser drops a database-engine-level user account.

func (*Manager) Explain

func (m *Manager) Explain(connID, database, query string, analyze bool) (QueryResult, error)

Explain runs a query through the connection's engine-native query-plan facility instead of executing it for results. Returns ErrUnsupported if the connected engine's adapter doesn't implement Explainer.

func (*Manager) GetColumns

func (m *Manager) GetColumns(connID, database, schema, table string) ([]QueryColumn, error)

GetColumns returns column metadata for a table.

func (*Manager) GetForeignKeys

func (m *Manager) GetForeignKeys(connID, database, schema, table string) ([]ForeignKey, error)

GetForeignKeys returns foreign key columns for a table.

func (*Manager) GetIndexes

func (m *Manager) GetIndexes(connID, database, schema, table string) ([]Index, error)

GetIndexes returns index metadata for a table.

func (*Manager) GrantPrivilege

func (m *Manager) GrantPrivilege(connID, username, privilege, database, schema, table string) error

GrantPrivilege grants privilege to username, scoped to database/schema/ table where the engine distinguishes those levels (empty = not scoped at that level).

func (*Manager) KVBackup

func (m *Manager) KVBackup(connID, database string) (string, error)

KVBackup generates a restorable NDJSON export of every key in database.

func (*Manager) KVCreateContainer

func (m *Manager) KVCreateContainer(connID, database, container string) error

KVCreateContainer creates a new container (e.g. a Mongo collection) inside a database.

func (*Manager) KVCreateDatabase

func (m *Manager) KVCreateDatabase(connID, name string) error

KVCreateDatabase creates a new database on a key-value connection.

func (*Manager) KVDeleteKey

func (m *Manager) KVDeleteKey(connID, database, key string) error

KVDeleteKey deletes a key.

func (*Manager) KVDropContainer

func (m *Manager) KVDropContainer(connID, database, container string) error

KVDropContainer drops a container inside a database.

func (*Manager) KVDropDatabase

func (m *Manager) KVDropDatabase(connID, name string) error

KVDropDatabase drops a database on a key-value connection.

func (*Manager) KVGetValue

func (m *Manager) KVGetValue(connID, database, key string) (KVValue, error)

KVGetValue returns a single key's type/TTL/value.

func (*Manager) KVListDatabases

func (m *Manager) KVListDatabases(connID string) ([]string, error)

KVListDatabases returns the key-value engine's databases (Redis: numbered DBs that have keys).

func (*Manager) KVListKeys

func (m *Manager) KVListKeys(connID, database, pattern string) ([]string, error)

KVListKeys returns keys matching pattern ("" = "*") in a database.

func (*Manager) KVRestore

func (m *Manager) KVRestore(connID, database, ndjson string) error

KVRestore parses an NDJSON export and replays it as SetValue calls, stopping at the first error.

func (*Manager) KVSetValue

func (m *Manager) KVSetValue(connID, database, key, value string) error

KVSetValue sets a string key's value (string type only, v1).

func (*Manager) KillSession

func (m *Manager) KillSession(connID, sessionID string) error

KillSession terminates a session/process on the connected engine's own server — a destructive action against possibly-unrelated client work, the caller is expected to have confirmed with the user first.

func (*Manager) ListDatabases

func (m *Manager) ListDatabases(connID string) ([]string, error)

ListDatabases returns available databases for an open connection.

func (*Manager) ListGrants

func (m *Manager) ListGrants(connID, username string) ([]GrantInfo, error)

ListGrants reports which privileges username currently holds. Returns ErrUnsupported if the adapter doesn't implement PrivilegeLister.

func (*Manager) ListSchemas

func (m *Manager) ListSchemas(connID, database string) ([]string, error)

ListSchemas returns schemas for a given database.

func (*Manager) ListSessions

func (m *Manager) ListSessions(connID string) ([]SessionInfo, error)

ListSessions lists active sessions/processes on the connected engine's own server. Returns ErrUnsupported if the adapter doesn't implement SessionManager.

func (*Manager) ListTables

func (m *Manager) ListTables(connID, database, schema string) ([]string, error)

ListTables returns tables for a database/schema.

func (*Manager) ListUsers

func (m *Manager) ListUsers(connID string) ([]UserInfo, error)

ListUsers lists database-engine-level user/role accounts. Returns ErrUnsupported if the adapter doesn't implement UserManager.

func (*Manager) Query

func (m *Manager) Query(connID, database, query string) (QueryResult, error)

Query executes arbitrary SQL and returns the result.

func (*Manager) Restore

func (m *Manager) Restore(connID, database, script string) error

Restore splits a backup script into statements and replays them sequentially against database, stopping at the first error.

func (*Manager) RevokePrivilege

func (m *Manager) RevokePrivilege(connID, username, privilege, database, schema, table string) error

RevokePrivilege revokes privilege from username, scoped like GrantPrivilege.

func (*Manager) Stats

func (m *Manager) Stats(connID string) (EngineStats, error)

Stats reports a snapshot of the connected engine's resource/activity metrics. Returns ErrUnsupported if the adapter doesn't implement StatsProvider.

type MongoDBDriver

type MongoDBDriver struct {
	// contains filtered or unexported fields
}

MongoDBDriver implements KVDriver. MongoDB has three levels (database, collection, document) but KVDriver only has two (database, key), so a "key" here is a compound "collection/docId" string — ListKeys returns these compound keys directly, and Get/Set/DeleteKey split on the first "/" to recover the collection and document id.

func (*MongoDBDriver) BackupDatabase

func (d *MongoDBDriver) BackupDatabase(ctx context.Context, database string) (string, error)

BackupDatabase exports every document across every collection in database as NDJSON, reusing ListKeys' "collection/docId" compound key format and GetValue's per-document JSON rendering so the export round-trips through SetValue during restore.

func (*MongoDBDriver) Capabilities

func (d *MongoDBDriver) Capabilities() Capabilities

func (*MongoDBDriver) Close

func (d *MongoDBDriver) Close() error

func (*MongoDBDriver) CreateContainer

func (d *MongoDBDriver) CreateContainer(ctx context.Context, database, container string) error

func (*MongoDBDriver) CreateDatabase

func (d *MongoDBDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase creates database by creating a placeholder collection in it — Mongo otherwise only creates databases lazily on first write, which wouldn't give the user an observable "created" effect.

func (*MongoDBDriver) CreateUser

func (d *MongoDBDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via createUser, run against admin with an empty roles array — a user with no roles yet is valid in Mongo, and roles are attached afterward via GrantPrivilege.

func (*MongoDBDriver) DeleteKey

func (d *MongoDBDriver) DeleteKey(ctx context.Context, database, key string) error

func (*MongoDBDriver) DropContainer

func (d *MongoDBDriver) DropContainer(ctx context.Context, database, container string) error

func (*MongoDBDriver) DropDatabase

func (d *MongoDBDriver) DropDatabase(ctx context.Context, name string) error

func (*MongoDBDriver) DropUser

func (d *MongoDBDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via dropUser, run against admin (see ListUsers for why admin is the convention used here).

func (*MongoDBDriver) GetValue

func (d *MongoDBDriver) GetValue(ctx context.Context, database, key string) (KVValue, error)

func (*MongoDBDriver) GrantPrivilege

func (d *MongoDBDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager. MongoDB's access model is role-based, not a per-call GRANT of an arbitrary privilege string like SQL — so here `privilege` is deliberately reinterpreted AS the name of a Mongo role (e.g. "readWrite", "dbAdmin", "read") to grant on `database` via grantRolesToUser. schema/table are ignored: Mongo roles don't scope below database level in a way this generic parameter set can express.

func (*MongoDBDriver) KillSession

func (d *MongoDBDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via the killOp admin command. id is the opid string as reported by ListSessions.

func (*MongoDBDriver) ListDatabases

func (d *MongoDBDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*MongoDBDriver) ListKeys

func (d *MongoDBDriver) ListKeys(ctx context.Context, database, pattern string) ([]string, error)

ListKeys lists documents across every collection in database, returning compound "collection/docId" keys, capped at 500 total.

func (*MongoDBDriver) ListSessions

func (d *MongoDBDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via the currentOp admin command, which lists in-flight operations across the whole server (not just one database).

func (*MongoDBDriver) ListUsers

func (d *MongoDBDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via usersInfo, run against the admin database — ListUsers takes no database argument, and admin is where cluster-wide user administration conventionally happens in Mongo.

func (*MongoDBDriver) RevokePrivilege

func (d *MongoDBDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager — see GrantPrivilege for the privilege-as-role-name mapping this mirrors via revokeRolesFromUser.

func (*MongoDBDriver) SetValue

func (d *MongoDBDriver) SetValue(ctx context.Context, database, key, value string) error

func (*MongoDBDriver) Stats

func (d *MongoDBDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider via serverStatus, run against the admin database (serverStatus is cluster/node-wide, not scoped to a particular database — Stats itself takes no database argument).

type MySQLDriver

type MySQLDriver struct {
	// contains filtered or unexported fields
}

MySQLDriver implements Driver for MySQL/MariaDB.

func (*MySQLDriver) BackupTable

func (d *MySQLDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*MySQLDriver) Capabilities

func (d *MySQLDriver) Capabilities() Capabilities

func (*MySQLDriver) Close

func (d *MySQLDriver) Close() error

func (*MySQLDriver) CreateDatabase

func (d *MySQLDriver) CreateDatabase(ctx context.Context, name string) error

func (*MySQLDriver) CreateSchema

func (d *MySQLDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: MySQL has no schema level separate from the database (see ListSchemas above).

func (*MySQLDriver) CreateTable

func (d *MySQLDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*MySQLDriver) CreateUser

func (d *MySQLDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager. username may be "user" or "user@host"; bare names default to "user@%" (any host), MySQL's usual convention.

func (*MySQLDriver) DropDatabase

func (d *MySQLDriver) DropDatabase(ctx context.Context, name string) error

func (*MySQLDriver) DropSchema

func (d *MySQLDriver) DropSchema(ctx context.Context, database, schema string) error

func (*MySQLDriver) DropTable

func (d *MySQLDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*MySQLDriver) DropUser

func (d *MySQLDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager.

func (*MySQLDriver) Explain

func (d *MySQLDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer. MySQL 8.0.18+ supports EXPLAIN ANALYZE natively; older versions ignore analyze and get a plain EXPLAIN (MySQL itself would error on EXPLAIN ANALYZE if unsupported, which surfaces to the caller as a normal query error).

func (*MySQLDriver) GetColumns

func (d *MySQLDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*MySQLDriver) GetForeignKeys

func (d *MySQLDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*MySQLDriver) GetIndexes

func (d *MySQLDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*MySQLDriver) GrantPrivilege

func (d *MySQLDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager (schema is ignored — MySQL's schema IS the database, see ListSchemas above).

func (*MySQLDriver) KillSession

func (d *MySQLDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via KILL.

func (*MySQLDriver) ListDatabases

func (d *MySQLDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*MySQLDriver) ListGrants

func (d *MySQLDriver) ListGrants(ctx context.Context, username string) ([]GrantInfo, error)

ListGrants implements PrivilegeLister by parsing SHOW GRANTS FOR — MySQL's privilege model is naturally per-database (unlike Postgres', which is per-table), so this maps directly onto the frontend's per-database grid without needing the aggregate-presence approximation postgres.go uses. Global grants (ON *.*) aren't tied to one database and are skipped — superusers hit this path but the frontend disables editing for them entirely, so it isn't a meaningful gap in practice.

func (*MySQLDriver) ListSchemas

func (d *MySQLDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*MySQLDriver) ListSessions

func (d *MySQLDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via SHOW PROCESSLIST.

func (*MySQLDriver) ListTables

func (d *MySQLDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*MySQLDriver) ListUsers

func (d *MySQLDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via mysql.user.

func (*MySQLDriver) Query

func (d *MySQLDriver) Query(ctx context.Context, database, query string) QueryResult

func (*MySQLDriver) RevokePrivilege

func (d *MySQLDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*MySQLDriver) Stats

func (d *MySQLDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider via SHOW GLOBAL STATUS.

type Neo4jDriver

type Neo4jDriver struct {
	// contains filtered or unexported fields
}

Neo4jDriver implements Driver for Neo4j. It's a graph database, not relational — this is a minimal mapping onto the existing tree/query UI rather than a real graph browser: node labels stand in for "tables" (GetColumns samples nodes to report property keys), and Query runs raw Cypher instead of SQL, flattened into the same tabular QueryResult. There is no dedicated node/relationship visualization.

Note: the neo4j-go-driver has no public custom-dialer hook, so SSH-tunneled connections aren't supported for Neo4j yet — only ConnectDirect.

func (*Neo4jDriver) BackupTable

func (d *Neo4jDriver) BackupTable(ctx context.Context, database, schema, label string) (string, error)

BackupTable renders every node carrying the given label as a `CREATE` Cypher statement so Restore (which replays a backup as a script of statements) can recreate them. Only recreates nodes, not relationships — relationships are already out of scope elsewhere in this driver (see GetForeignKeys), and a node-only backup is an honest, well-known limitation rather than a silent one.

func (*Neo4jDriver) Capabilities

func (d *Neo4jDriver) Capabilities() Capabilities

func (*Neo4jDriver) Close

func (d *Neo4jDriver) Close() error

func (*Neo4jDriver) CreateDatabase

func (d *Neo4jDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase runs CREATE DATABASE against the "system" database, per Neo4j's multi-database administration model. This only works on Enterprise edition; Community will return the server's own clear error, which we let propagate as-is rather than trying to detect the edition ourselves.

func (*Neo4jDriver) CreateSchema

func (d *Neo4jDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema: schema is fixed to "default" for this engine.

func (*Neo4jDriver) CreateTable

func (d *Neo4jDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

CreateTable/DropTable: a label has no DDL — "creating" one means inserting nodes carrying it (there's nothing to create ahead of time), and "dropping" one would mean deleting every node with that label, which is a far more destructive/ambiguous operation than a table drop and shouldn't be offered under that name.

func (*Neo4jDriver) CreateUser

func (d *Neo4jDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via CREATE USER ... SET PASSWORD, against the "system" database. Enterprise-only, same caveat as ListUsers.

func (*Neo4jDriver) DropDatabase

func (d *Neo4jDriver) DropDatabase(ctx context.Context, name string) error

DropDatabase runs DROP DATABASE against the "system" database.

func (*Neo4jDriver) DropSchema

func (d *Neo4jDriver) DropSchema(ctx context.Context, database, schema string) error

func (*Neo4jDriver) DropTable

func (d *Neo4jDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*Neo4jDriver) DropUser

func (d *Neo4jDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DROP USER, against "system". Enterprise-only, same caveat as ListUsers.

func (*Neo4jDriver) Explain

func (d *Neo4jDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer using Cypher's own native EXPLAIN/PROFILE query prefixes. EXPLAIN returns the plan without running the query (so Records is typically empty — that's a legitimate "no resultset" outcome, not an error); PROFILE actually runs it and additionally attaches profiled timings/row counts to the ResultSummary, but rendering that plan tree as text is left as a nice-to-have for later — the row data PROFILE produces (like a normal query) is returned here the same way Query does it.

func (*Neo4jDriver) GetColumns

func (d *Neo4jDriver) GetColumns(ctx context.Context, database, schema, label string) ([]QueryColumn, error)

func (*Neo4jDriver) GetForeignKeys

func (d *Neo4jDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*Neo4jDriver) GetIndexes

func (d *Neo4jDriver) GetIndexes(ctx context.Context, database, schema, label string) ([]Index, error)

func (*Neo4jDriver) GrantPrivilege

func (d *Neo4jDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager as GRANT ROLE ... TO USER ...: Neo4j's real privilege grammar (GRANT MATCH {*} ON GRAPH * ...) is fine-grained but doesn't map onto this interface's flat (privilege, database, schema, table) shape, so privilege is treated as the name of an existing role to attach to username instead — database/schema/ table are ignored, a role grant isn't scoped to any of those levels the way a relational GRANT is. Enterprise-only, same caveat as ListUsers.

func (*Neo4jDriver) KillSession

func (d *Neo4jDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via TERMINATE TRANSACTIONS, which (like SHOW TRANSACTIONS) takes a list of transaction ids — passed here as a single-element parameter list rather than splicing the id into the query text.

func (*Neo4jDriver) ListDatabases

func (d *Neo4jDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*Neo4jDriver) ListSchemas

func (d *Neo4jDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*Neo4jDriver) ListSessions

func (d *Neo4jDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via SHOW TRANSACTIONS, which lists every in-progress transaction on the server (including its currently running query, if any) — Neo4j's closest equivalent to a process list. Unlike SHOW USERS/CREATE USER/etc. below, SHOW TRANSACTIONS is NOT Enterprise-only: Community edition supports it too (scoped to its single default database), so this should work on either edition.

DurationMs is left at zero: SHOW TRANSACTIONS exposes elapsed time as a Duration-typed column, not a millisecond scalar, and converting that precisely isn't attempted here (SessionInfo's own doc comment allows fields that don't cleanly apply to be left at their zero value).

func (*Neo4jDriver) ListTables

func (d *Neo4jDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*Neo4jDriver) ListUsers

func (d *Neo4jDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via SHOW USERS, run against the "system" database per Neo4j's administration model — same pattern CreateDatabase already uses. Like CreateDatabase, this is Enterprise-only in real Neo4j (Community has no role-based access control); on Community this simply surfaces the server's own error, which we let propagate as-is rather than trying to detect the edition ourselves.

func (*Neo4jDriver) Query

func (d *Neo4jDriver) Query(ctx context.Context, database, cypher string) QueryResult

func (*Neo4jDriver) RevokePrivilege

func (d *Neo4jDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager as REVOKE ROLE ... FROM USER ..., the counterpart of GrantPrivilege above.

func (*Neo4jDriver) Stats

func (d *Neo4jDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider with a single, edition-agnostic reading: the number of currently active transactions via SHOW TRANSACTIONS. The richer per-JMX-bean metrics (CALL dbms.queryJmx(...)) are Enterprise-only and considerably more involved to map onto a flat StatMetric list, so they're skipped in favor of this one reliable number.

type NetDriverFactory

type NetDriverFactory func(ctx context.Context, id string, params ConnParams) (Driver, error)

NetDriverFactory constructs and connects a Driver for a network-based engine, verifying connectivity before returning (so callers get a real connection error immediately rather than on first use).

type OracleDriver

type OracleDriver struct {
	// contains filtered or unexported fields
}

OracleDriver implements Driver for Oracle Database.

Oracle has no "list of databases" concept the way Postgres/MySQL do — one connection is always scoped to a single service (ConnParams.Database). What other engines call a "schema" maps to an Oracle user/owner, so ListSchemas here returns real Oracle schemas (all_users) rather than a single fixed value — same "collapse when there's only one" sidebar rule as SQL Server applies naturally.

Note: go-ora has no public custom-dialer hook (unlike pgx/go-mssqldb/ go-redis), so SSH-tunneled connections aren't supported for Oracle yet — only ConnectDirect. Connect (tunneled) will fail at dial time if attempted.

func (*OracleDriver) BackupTable

func (d *OracleDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*OracleDriver) Capabilities

func (d *OracleDriver) Capabilities() Capabilities

func (*OracleDriver) Close

func (d *OracleDriver) Close() error

func (*OracleDriver) CreateDatabase

func (d *OracleDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase/DropDatabase are unsupported: a connection is always scoped to a single fixed service/database (ConnParams.Database, see ListDatabases above) — there's no server-level database to create/drop.

func (*OracleDriver) CreateSchema

func (d *OracleDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: an Oracle "schema" is really a user/login (CREATE USER "name" IDENTIFIED BY <password>), and this API has no natural source for a password to assign that user. Rather than invent or derive one, we surface this as unsupported instead of doing something surprising with credentials.

func (*OracleDriver) CreateTable

func (d *OracleDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*OracleDriver) CreateUser

func (d *OracleDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via CREATE USER ... IDENTIFIED BY. This is distinct from the CreateSchema ErrUnsupported case above: Oracle "schemas" there had no password source to draw from, while this interface's CreateUser takes one explicitly, so it's a legitimate fit here.

func (*OracleDriver) DropDatabase

func (d *OracleDriver) DropDatabase(ctx context.Context, name string) error

func (*OracleDriver) DropSchema

func (d *OracleDriver) DropSchema(ctx context.Context, database, schema string) error

func (*OracleDriver) DropTable

func (d *OracleDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*OracleDriver) DropUser

func (d *OracleDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DROP USER ... CASCADE.

func (*OracleDriver) Explain

func (d *OracleDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer via EXPLAIN PLAN FOR + DBMS_XPLAN.DISPLAY. The closer analog for analyze (actually running the query and reporting real timings via DBMS_XPLAN.DISPLAY_CURSOR) needs a session-pinned two-step SQL_ID lookup that doesn't map cleanly onto this driver's ad hoc *sql.DB access — analyze is ignored and the static plan is always returned instead.

func (*OracleDriver) GetColumns

func (d *OracleDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*OracleDriver) GetForeignKeys

func (d *OracleDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*OracleDriver) GetIndexes

func (d *OracleDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*OracleDriver) GrantPrivilege

func (d *OracleDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager (database is ignored — a connection is always scoped to one fixed service, see ListDatabases above).

func (*OracleDriver) KillSession

func (d *OracleDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via ALTER SYSTEM KILL SESSION. id is expected in Oracle's own "sid,serial#" form, exactly as returned by ListSessions above.

func (*OracleDriver) ListDatabases

func (d *OracleDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*OracleDriver) ListSchemas

func (d *OracleDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*OracleDriver) ListSessions

func (d *OracleDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via v$session joined to v$sql for the currently executing statement's text.

func (*OracleDriver) ListTables

func (d *OracleDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*OracleDriver) ListUsers

func (d *OracleDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via dba_users.

func (*OracleDriver) Query

func (d *OracleDriver) Query(ctx context.Context, database, query string) QueryResult

func (*OracleDriver) RevokePrivilege

func (d *OracleDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*OracleDriver) Stats

func (d *OracleDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider with a couple of minimal, broadly-available metrics — v$session for connection count and a tablespace usage total.

type PostgresDriver

type PostgresDriver struct {
	// contains filtered or unexported fields
}

PostgresDriver implements Driver for PostgreSQL/TimescaleDB.

func (*PostgresDriver) BackupTable

func (d *PostgresDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*PostgresDriver) Capabilities

func (d *PostgresDriver) Capabilities() Capabilities

func (*PostgresDriver) Close

func (d *PostgresDriver) Close() error

func (*PostgresDriver) CreateDatabase

func (d *PostgresDriver) CreateDatabase(ctx context.Context, name string) error

func (*PostgresDriver) CreateSchema

func (d *PostgresDriver) CreateSchema(ctx context.Context, database, schema string) error

func (*PostgresDriver) CreateTable

func (d *PostgresDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*PostgresDriver) CreateUser

func (d *PostgresDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via CREATE ROLE ... LOGIN.

func (*PostgresDriver) DropDatabase

func (d *PostgresDriver) DropDatabase(ctx context.Context, name string) error

func (*PostgresDriver) DropSchema

func (d *PostgresDriver) DropSchema(ctx context.Context, database, schema string) error

func (*PostgresDriver) DropTable

func (d *PostgresDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*PostgresDriver) DropUser

func (d *PostgresDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DROP ROLE.

func (*PostgresDriver) Explain

func (d *PostgresDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer.

func (*PostgresDriver) GetColumns

func (d *PostgresDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*PostgresDriver) GetForeignKeys

func (d *PostgresDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*PostgresDriver) GetIndexes

func (d *PostgresDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*PostgresDriver) GrantPrivilege

func (d *PostgresDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager. Runs against database's own pool (not the "postgres" maintenance connection) since schema/table grants are database-local — connecting to the wrong database would silently grant on that database's "public" schema instead of the one the caller asked for.

func (*PostgresDriver) KillSession

func (d *PostgresDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via pg_terminate_backend.

func (*PostgresDriver) ListDatabases

func (d *PostgresDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*PostgresDriver) ListGrants

func (d *PostgresDriver) ListGrants(ctx context.Context, username string) ([]GrantInfo, error)

ListGrants implements PrivilegeLister: for each database, reports which of the common table-data privileges the user holds on ANY table in it — an aggregate presence check (via information_schema.role_table_grants), not a per-table breakdown, matching the granularity the frontend's "which databases does this user have access to" grid actually needs. Schema/ Table are left "" since this reports at database granularity.

func (*PostgresDriver) ListSchemas

func (d *PostgresDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*PostgresDriver) ListSessions

func (d *PostgresDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via pg_stat_activity.

func (*PostgresDriver) ListTables

func (d *PostgresDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*PostgresDriver) ListUsers

func (d *PostgresDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via pg_roles.

func (*PostgresDriver) Query

func (d *PostgresDriver) Query(ctx context.Context, database, query string) QueryResult

func (*PostgresDriver) RevokePrivilege

func (d *PostgresDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*PostgresDriver) Stats

func (d *PostgresDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider — a snapshot of pg_stat_database (scoped to the given database) plus a server-wide connection count.

type PrivilegeLister

type PrivilegeLister interface {
	ListGrants(ctx context.Context, username string) ([]GrantInfo, error)
}

PrivilegeLister reports which privileges a user currently holds, so the frontend can show real state (a checked box = an actual grant) instead of a blind "what to apply" form. This is a separate, optional interface from UserManager because introspecting *current* grants is meaningfully harder than issuing a GRANT/REVOKE statement for several engines — implement it only where the engine's own catalog makes this reliable (Postgres, MySQL); engines without it simply don't implement this interface, and the frontend falls back to an unchecked "select what to grant" form.

type QueryColumn

type QueryColumn struct {
	Name     string `json:"name"`
	DataType string `json:"dataType"`
	Nullable bool   `json:"nullable"`
	Default  string `json:"default"`
	Key      string `json:"key"`
}

QueryColumn describes a single column returned by GetColumns.

type QueryResult

type QueryResult struct {
	Columns  []string   `json:"columns"`
	Rows     [][]string `json:"rows"`
	RowCount int        `json:"rowCount"`
	Error    string     `json:"error"`
	Graph    *GraphData `json:"graph,omitempty"`
}

QueryResult is the tabular result of a Query call. Graph is populated alongside the tabular Columns/Rows (never instead of) for engines whose results carry graph structure, e.g. Neo4j nodes/relationships/paths — the frontend uses it to offer a node-link visualization next to the table.

type RedisDriver

type RedisDriver struct {
	// contains filtered or unexported fields
}

RedisDriver implements KVDriver. Redis' 16 numbered databases (0-15 by default) stand in for "databases" — ListDatabases reports which ones actually have keys (via INFO keyspace) rather than a fixed 0-15 list, since most deployments only use db0.

func (*RedisDriver) BackupDatabase

func (d *RedisDriver) BackupDatabase(ctx context.Context, database string) (string, error)

BackupDatabase exports every key in database as NDJSON, reusing ListKeys (pattern "*") and GetValue's type-aware rendering.

func (*RedisDriver) Capabilities

func (d *RedisDriver) Capabilities() Capabilities

func (*RedisDriver) Close

func (d *RedisDriver) Close() error

func (*RedisDriver) CreateContainer

func (d *RedisDriver) CreateContainer(ctx context.Context, database, container string) error

CreateContainer/DropContainer are unsupported: Redis has a flat key space with no grouping unit under a numbered database.

func (*RedisDriver) CreateDatabase

func (d *RedisDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase/DropDatabase are unsupported: Redis' 16 numbered databases always exist (there's nothing to "create"), and the closest analog to "drop" would be FLUSHDB — a data wipe, not a structural drop — so we don't conflate the two here.

func (*RedisDriver) CreateUser

func (d *RedisDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via ACL SETUSER, enabling the user and granting a permissive default (all keys, all commands) so the account is immediately usable — narrower access is expected to follow via GrantPrivilege/RevokePrivilege using ACL rule tokens.

func (*RedisDriver) DeleteKey

func (d *RedisDriver) DeleteKey(ctx context.Context, database, key string) error

func (*RedisDriver) DropContainer

func (d *RedisDriver) DropContainer(ctx context.Context, database, container string) error

func (*RedisDriver) DropDatabase

func (d *RedisDriver) DropDatabase(ctx context.Context, name string) error

func (*RedisDriver) DropUser

func (d *RedisDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via ACL DELUSER.

func (*RedisDriver) GetValue

func (d *RedisDriver) GetValue(ctx context.Context, database, key string) (KVValue, error)

func (*RedisDriver) GrantPrivilege

func (d *RedisDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager via ACL SETUSER <user> +<privilege>. Redis ACL rules use their own +/- prefixed syntax rather than SQL-style GRANT, so `privilege` here is expected to already be a Redis ACL rule token without its sign ("get", "@read", "@write", ...) — the "+" is prepended here. database/schema/table are ignored: Redis ACL rules don't scope by database/schema/table, only by key pattern and command/category.

func (*RedisDriver) KillSession

func (d *RedisDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via CLIENT KILL ID <id>.

func (*RedisDriver) ListDatabases

func (d *RedisDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*RedisDriver) ListKeys

func (d *RedisDriver) ListKeys(ctx context.Context, database, pattern string) ([]string, error)

func (*RedisDriver) ListSessions

func (d *RedisDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via CLIENT LIST, which reports every connected client server-wide (not scoped to one selected database).

func (*RedisDriver) ListUsers

func (d *RedisDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via ACL LIST (Redis 6+). Roles carries the raw ACL rule tokens for that user (there's no separate "role" concept in Redis ACL beyond the rule set itself); Superuser is heuristically true when the rules include the built-in "allkeys"/"allcommands"-equivalent "+@all" grant.

func (*RedisDriver) RevokePrivilege

func (d *RedisDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager via ACL SETUSER <user> -<privilege> — see GrantPrivilege for the ACL-rule-token mapping this mirrors.

func (*RedisDriver) SetValue

func (d *RedisDriver) SetValue(ctx context.Context, database, key, value string) error

func (*RedisDriver) Stats

func (d *RedisDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider via INFO, run against the default (db0) client — Stats takes no database argument, and INFO itself reports server-wide figures rather than per-database ones.

type SQLServerDriver

type SQLServerDriver struct {
	// contains filtered or unexported fields
}

SQLServerDriver implements Driver for Microsoft SQL Server / Azure SQL. Schemas are real here (dbo, plus any custom schema), so the sidebar's "collapse when there's only one schema" rule naturally shows them.

func (*SQLServerDriver) BackupTable

func (d *SQLServerDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*SQLServerDriver) Capabilities

func (d *SQLServerDriver) Capabilities() Capabilities

func (*SQLServerDriver) Close

func (d *SQLServerDriver) Close() error

func (*SQLServerDriver) CreateDatabase

func (d *SQLServerDriver) CreateDatabase(ctx context.Context, name string) error

func (*SQLServerDriver) CreateSchema

func (d *SQLServerDriver) CreateSchema(ctx context.Context, database, schema string) error

func (*SQLServerDriver) CreateTable

func (d *SQLServerDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*SQLServerDriver) CreateUser

func (d *SQLServerDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager via CREATE LOGIN ... WITH PASSWORD.

func (*SQLServerDriver) DropDatabase

func (d *SQLServerDriver) DropDatabase(ctx context.Context, name string) error

func (*SQLServerDriver) DropSchema

func (d *SQLServerDriver) DropSchema(ctx context.Context, database, schema string) error

DropSchema lets SQL Server's own error surface when the schema isn't empty — SQL Server has no CASCADE for schemas, so we don't add destructive workaround logic to force it through.

func (*SQLServerDriver) DropTable

func (d *SQLServerDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*SQLServerDriver) DropUser

func (d *SQLServerDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager via DROP LOGIN.

func (*SQLServerDriver) Explain

func (d *SQLServerDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer. SQL Server's real plan capture (SET SHOWPLAN_XML ON) must run in the SAME session as the statement and must NOT actually execute it — this needs a single reserved *sql.Conn rather than the pool-style ad hoc connections Query() uses, so it's implemented directly against one connection pulled from the database's pool and returned immediately after.

func (*SQLServerDriver) GetColumns

func (d *SQLServerDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*SQLServerDriver) GetForeignKeys

func (d *SQLServerDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*SQLServerDriver) GetIndexes

func (d *SQLServerDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*SQLServerDriver) GrantPrivilege

func (d *SQLServerDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager. Table/schema-scoped grants target the object/schema; a database-only scope grants a database-level permission with no ON clause.

func (*SQLServerDriver) KillSession

func (d *SQLServerDriver) KillSession(ctx context.Context, id string) error

KillSession implements SessionManager via KILL <session_id>.

func (*SQLServerDriver) ListDatabases

func (d *SQLServerDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*SQLServerDriver) ListSchemas

func (d *SQLServerDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*SQLServerDriver) ListSessions

func (d *SQLServerDriver) ListSessions(ctx context.Context) ([]SessionInfo, error)

ListSessions implements SessionManager via sys.dm_exec_sessions joined to sys.dm_exec_requests (running query) and sys.dm_exec_sql_text (query text).

func (*SQLServerDriver) ListTables

func (d *SQLServerDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*SQLServerDriver) ListUsers

func (d *SQLServerDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via sys.server_principals/sys.sql_logins.

func (*SQLServerDriver) Query

func (d *SQLServerDriver) Query(ctx context.Context, database, query string) QueryResult

func (*SQLServerDriver) RevokePrivilege

func (d *SQLServerDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

func (*SQLServerDriver) Stats

func (d *SQLServerDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider via sys.dm_exec_sessions/sys.databases/ sys.master_files.

type SQLiteDriver

type SQLiteDriver struct {
	// contains filtered or unexported fields
}

SQLiteDriver implements Driver for a local SQLite file. Unlike the network engines, SQLite doesn't go through the ConnParams/DialFunc registry — it's opened directly from a local path (see manager.go's ConnectSQLite/ConnectLocalSQLite, which handle the SFTP download/upload for remote files; that transport concern is orthogonal to SQL access and deliberately kept out of this driver).

func (*SQLiteDriver) BackupTable

func (d *SQLiteDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*SQLiteDriver) Capabilities

func (d *SQLiteDriver) Capabilities() Capabilities

func (*SQLiteDriver) Close

func (d *SQLiteDriver) Close() error

func (*SQLiteDriver) CreateDatabase

func (d *SQLiteDriver) CreateDatabase(ctx context.Context, name string) error

CreateDatabase/DropDatabase are unsupported: a SQLiteDriver is bound to a single fixed database file per connection (see ListDatabases above) — there's no server-level concept to create/drop another one against.

func (*SQLiteDriver) CreateSchema

func (d *SQLiteDriver) CreateSchema(ctx context.Context, database, schema string) error

CreateSchema/DropSchema are unsupported: SQLite's only schema is the fixed "main" (see ListSchemas above), nothing to create/drop.

func (*SQLiteDriver) CreateTable

func (d *SQLiteDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*SQLiteDriver) DropDatabase

func (d *SQLiteDriver) DropDatabase(ctx context.Context, name string) error

func (*SQLiteDriver) DropSchema

func (d *SQLiteDriver) DropSchema(ctx context.Context, database, schema string) error

func (*SQLiteDriver) DropTable

func (d *SQLiteDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*SQLiteDriver) Explain

func (d *SQLiteDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer via EXPLAIN QUERY PLAN. SQLite has no "actually run it and report real timings" plan variant the way Postgres/ MySQL EXPLAIN ANALYZE do, so analyze is ignored — EXPLAIN QUERY PLAN is always a static plan.

func (*SQLiteDriver) GetColumns

func (d *SQLiteDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*SQLiteDriver) GetForeignKeys

func (d *SQLiteDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*SQLiteDriver) GetIndexes

func (d *SQLiteDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*SQLiteDriver) ListDatabases

func (d *SQLiteDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*SQLiteDriver) ListSchemas

func (d *SQLiteDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*SQLiteDriver) ListTables

func (d *SQLiteDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*SQLiteDriver) Query

func (d *SQLiteDriver) Query(ctx context.Context, database, query string) QueryResult

func (*SQLiteDriver) Stats

func (d *SQLiteDriver) Stats(ctx context.Context) (EngineStats, error)

Stats implements StatsProvider with cheap file-based/PRAGMA metrics — SQLite has no server process to report connection counts or hit ratios for, so this stays to what a single local file can meaningfully expose.

type SessionInfo

type SessionInfo struct {
	ID         string `json:"id"`
	User       string `json:"user"`
	Client     string `json:"client"`
	Database   string `json:"database"`
	State      string `json:"state"`
	Query      string `json:"query"`
	DurationMs int64  `json:"durationMs"`
}

SessionInfo describes one active session/connection/process on the connected database engine's own server — NOT one of navoro's own open connections (see Manager.conns/kvConns for that, an unrelated concept). Fields that don't apply to a given engine are left as their zero value.

type SessionManager

type SessionManager interface {
	ListSessions(ctx context.Context) ([]SessionInfo, error)
	KillSession(ctx context.Context, id string) error
}

SessionManager lists and terminates sessions on the connected engine's own server. KillSession is a destructive, irreversible action against possibly-unrelated client work — callers must confirm before invoking it.

type SnowflakeDriver

type SnowflakeDriver struct {
	// contains filtered or unexported fields
}

SnowflakeDriver implements Driver for Snowflake. Snowflake is a cloud data warehouse reached over HTTPS by account identifier, not host:port — ConnParams.Host is repurposed as the account identifier, and ConnParams.Database as the initial database. It's always accessed directly over the internet (never via an on-prem SSH tunnel), so ConnParams.Dial is not supported/used here.

func (*SnowflakeDriver) BackupTable

func (d *SnowflakeDriver) BackupTable(ctx context.Context, database, schema, table string) (string, error)

func (*SnowflakeDriver) Capabilities

func (d *SnowflakeDriver) Capabilities() Capabilities

func (*SnowflakeDriver) Close

func (d *SnowflakeDriver) Close() error

func (*SnowflakeDriver) CreateDatabase

func (d *SnowflakeDriver) CreateDatabase(ctx context.Context, name string) error

func (*SnowflakeDriver) CreateSchema

func (d *SnowflakeDriver) CreateSchema(ctx context.Context, database, schema string) error

func (*SnowflakeDriver) CreateTable

func (d *SnowflakeDriver) CreateTable(ctx context.Context, database, schema, table string, columns []ColumnDef) error

func (*SnowflakeDriver) CreateUser

func (d *SnowflakeDriver) CreateUser(ctx context.Context, username, password string) error

CreateUser implements UserManager.

func (*SnowflakeDriver) DropDatabase

func (d *SnowflakeDriver) DropDatabase(ctx context.Context, name string) error

func (*SnowflakeDriver) DropSchema

func (d *SnowflakeDriver) DropSchema(ctx context.Context, database, schema string) error

func (*SnowflakeDriver) DropTable

func (d *SnowflakeDriver) DropTable(ctx context.Context, database, schema, table string) error

func (*SnowflakeDriver) DropUser

func (d *SnowflakeDriver) DropUser(ctx context.Context, username string) error

DropUser implements UserManager.

func (*SnowflakeDriver) Explain

func (d *SnowflakeDriver) Explain(ctx context.Context, database, query string, analyze bool) (QueryResult, error)

Explain implements Explainer via EXPLAIN USING TEXT. Snowflake has no single-statement "run it for real and report actual timings" analog — that requires pulling QUERY_HISTORY/QUERY_PROFILE after the fact — so analyze is ignored and the static text plan is always returned.

func (*SnowflakeDriver) GetColumns

func (d *SnowflakeDriver) GetColumns(ctx context.Context, database, schema, table string) ([]QueryColumn, error)

func (*SnowflakeDriver) GetForeignKeys

func (d *SnowflakeDriver) GetForeignKeys(ctx context.Context, database, schema, table string) ([]ForeignKey, error)

func (*SnowflakeDriver) GetIndexes

func (d *SnowflakeDriver) GetIndexes(ctx context.Context, database, schema, table string) ([]Index, error)

func (*SnowflakeDriver) GrantPrivilege

func (d *SnowflakeDriver) GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error

GrantPrivilege implements UserManager.

func (*SnowflakeDriver) ListDatabases

func (d *SnowflakeDriver) ListDatabases(ctx context.Context) ([]string, error)

func (*SnowflakeDriver) ListSchemas

func (d *SnowflakeDriver) ListSchemas(ctx context.Context, database string) ([]string, error)

func (*SnowflakeDriver) ListTables

func (d *SnowflakeDriver) ListTables(ctx context.Context, database, schema string) ([]string, error)

func (*SnowflakeDriver) ListUsers

func (d *SnowflakeDriver) ListUsers(ctx context.Context) ([]UserInfo, error)

ListUsers implements UserManager via SHOW USERS.

func (*SnowflakeDriver) Query

func (d *SnowflakeDriver) Query(ctx context.Context, database, query string) QueryResult

func (*SnowflakeDriver) RevokePrivilege

func (d *SnowflakeDriver) RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error

RevokePrivilege implements UserManager.

type StatMetric

type StatMetric struct {
	Label string  `json:"label"`
	Value float64 `json:"value"`
	Unit  string  `json:"unit"`
}

StatMetric is one point-in-time numeric reading from StatsProvider.Stats. Unit is a short free-form label the frontend displays alongside Value ("MB", "ms", "%", "/s", "count", ...) — engines expose wildly different metrics, so this stays a flexible list rather than a fixed schema.

type StatsProvider

type StatsProvider interface {
	Stats(ctx context.Context) (EngineStats, error)
}

StatsProvider reports a snapshot of engine-level resource/activity metrics (active connections, cache hit ratio, database size, ...).

type UserInfo

type UserInfo struct {
	Name      string   `json:"name"`
	Roles     []string `json:"roles"`
	Superuser bool     `json:"superuser"`
}

UserInfo describes one database-engine-level user/role account — wholly separate from vault.DBConnection (navoro's own saved-connection credentials used to connect in the first place).

type UserManager

type UserManager interface {
	ListUsers(ctx context.Context) ([]UserInfo, error)
	CreateUser(ctx context.Context, username, password string) error
	DropUser(ctx context.Context, username string) error
	GrantPrivilege(ctx context.Context, username, privilege, database, schema, table string) error
	RevokePrivilege(ctx context.Context, username, privilege, database, schema, table string) error
}

UserManager manages database-engine-level user accounts and privileges. Privilege is free text in the target engine's own grant vocabulary ("SELECT", "ALL", "readWrite", ...) rather than a fixed enum, since that vocabulary differs completely across engines. database/schema/table are the privilege's scope; engines that don't distinguish a level ignore the corresponding empty/irrelevant argument.

Jump to

Keyboard shortcuts

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