Documentation
¶
Overview ¶
Package db provides the SQL execution engine for CommitDB.
The Engine type is the main entry point for executing SQL statements. It parses SQL, executes queries, and returns results.
Engine Usage ¶
engine := db.NewEngine(persistence, identity)
result, err := engine.Execute("SELECT * FROM mydb.users")
if err != nil {
log.Fatal(err)
}
result.Display()
Result Types ¶
There are two result types:
- QueryResult: Returned by SELECT statements
- CommitResult: Returned by INSERT, UPDATE, DELETE, CREATE, DROP
QueryResult contains columns, data rows, and execution metrics. CommitResult contains counts of affected objects and the transaction ID.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitResult ¶
type CommitResult struct {
Transaction ps.Transaction
DatabasesCreated int
DatabasesDeleted int
TablesCreated int
TablesDeleted int
TablesAltered int
RecordsWritten int
RecordsDeleted int
ExecutionTimeSec float64
ExecutionOps int
}
func (CommitResult) Display ¶
func (result CommitResult) Display()
func (CommitResult) ExecutionTime ¶
func (result CommitResult) ExecutionTime() string
func (CommitResult) Type ¶
func (result CommitResult) Type() ResultType
type Engine ¶
type Engine struct {
*ps.Persistence
QueryContext
}
type QueryContext ¶
type QueryResult ¶
type QueryResult struct {
Transaction ps.Transaction
Columns []string
Data [][]string
RecordsRead int
ExecutionTimeSec float64
ExecutionOps int
}
func (QueryResult) Display ¶
func (result QueryResult) Display()
func (QueryResult) ExecutionTime ¶
func (result QueryResult) ExecutionTime() string
func (QueryResult) Type ¶
func (result QueryResult) Type() ResultType
type Result ¶
type Result interface {
Type() ResultType
Display()
}
type SimpleTable ¶
type SimpleTable struct {
// contains filtered or unexported fields
}
SimpleTable provides basic table formatting without external dependencies
func (*SimpleTable) Header ¶
func (t *SimpleTable) Header(headers []string)
Header sets the table headers
Click to show internal directories.
Click to hide internal directories.