Documentation
¶
Index ¶
- type Session
- func (s *Session) CLI() string
- func (s *Session) Close()
- func (s *Session) Connect() error
- func (s *Session) Count(table, where string) (string, error)
- func (s *Session) Describe(table string) (string, error)
- func (s *Session) Exec(query string) (string, error)
- func (s *Session) ExecCLIQuery(query, param string) (string, error)
- func (s *Session) ExecCLIQueryFormatted(query, param string) (string, error)
- func (s *Session) ExecFormatted(query string) (string, error)
- func (s *Session) ExecNative(query string) (string, error)
- func (s *Session) Find(table, id string) (string, error)
- func (s *Session) HasNativeConn() bool
- func (s *Session) Indexes(table string) (string, error)
- func (s *Session) ModernCLIAvailable() string
- func (s *Session) Ping() error
- func (s *Session) Schema(table string) (string, error)
- func (s *Session) Size() (string, error)
- func (s *Session) Tables() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
Driver string
DSN string
Type string
// contains filtered or unexported fields
}
Session holds database connection info and an optional native database/sql connection.
func NewSession ¶
NewSession creates a new database session from config.
func (*Session) Close ¶ added in v0.19.0
func (s *Session) Close()
Close closes the native database connection if open.
func (*Session) Connect ¶
Connect opens an interactive database session using the best available CLI. With native drivers compiled in, interactive sessions are the only reason to shell out to external CLIs.
func (*Session) Count ¶
Count returns the count of rows in a table. Table name is validated; WHERE clause is treated as a raw SQL condition (user is responsible for safety).
func (*Session) Describe ¶
Describe shows the schema of a table. Table name is validated against the database.
func (*Session) Exec ¶
Exec runs a query via an external CLI tool (fallback when no native connection). Prefer using native database/sql queries via the session's methods instead.
func (*Session) ExecCLIQuery ¶ added in v0.19.0
ExecCLIQuery runs a query via the external CLI with a single parameter.
func (*Session) ExecCLIQueryFormatted ¶ added in v0.21.0
ExecCLIQueryFormatted runs a formatted query via the external CLI with a single parameter.
func (*Session) ExecFormatted ¶ added in v0.21.0
ExecFormatted runs a query with tabular formatting via an external CLI tool (fallback when no native connection). Prefer using native database/sql queries via the session's methods instead.
func (*Session) ExecNative ¶ added in v0.25.0
ExecNative runs a raw SQL query via the native connection and returns formatted table results using go-pretty. Returns ("", nil) if no native connection.
func (*Session) Find ¶
Find returns a single row by ID. Table name is validated; ID uses parameterized query.
func (*Session) HasNativeConn ¶ added in v0.19.0
HasNativeConn returns true if a native database/sql connection is available.
func (*Session) ModernCLIAvailable ¶ added in v0.17.0
ModernCLIAvailable returns the modern CLI name for the current driver (even if not installed), used for hint messages.
func (*Session) Schema ¶ added in v0.22.0
Schema returns the CREATE TABLE statement for a table (with syntax highlighting).