Documentation
¶
Overview ¶
Package query provides a set of functions for interacting with SQL databases, including executing queries, updating rows, and performing various database operations.
This package includes functionalities for:
- Executing SQL queries.
- Updating rows in database tables.
- Retrieving and handling column data types.
- Wrapping values and primary keys for SQL update statements.
- Performing database operations such as dropping tables, truncating tables, dropping databases, and creating databases.
Index ¶
- type Query
- type Result
- func CreateDatabase(dbname string, db *sql.DB) (*Result, error)
- func DropDatabase(dbname string, db *sql.DB) (*Result, error)
- func DropTable(table, dbname string, db *sql.DB) (*Result, error)
- func ExecuteQuery(q *Query, client *_client.Client) (*Result, error)
- func TruncateTable(table, dbname string, db *sql.DB) (*Result, error)
- func UpdateRow(table, parentCol, newVal, priKeyVal, priKeyCol string, client *_client.Client) (*Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
AffectedRows int64 `json:"affected_rows"`
Time string `json:"time_taken"`
Data []map[string]interface{} `json:"data"`
Msg string `json:"message"`
}
Result represents the result of a database operation.
func UpdateRow ¶
func UpdateRow(table, parentCol, newVal, priKeyVal, priKeyCol string, client *_client.Client) (*Result, error)
UpdateRow constructs and executes an SQL UPDATE statement to modify a row in the specified table. The function handles checking the column data type, and wraps its value in single quotes if necessary. Returns the result of the update operation or any encountered errors.
Click to show internal directories.
Click to hide internal directories.