MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Query

Method Query

sqlchain/adapter/storage/sqlite3.go:77–116  ·  view source on GitHub ↗

Query implements the Storage abstraction interface.

(dbID string, query string, args ...interface{})

Source from the content-addressed store, hash-verified

75
76// Query implements the Storage abstraction interface.
77func (s *SQLite3Storage) Query(dbID string, query string, args ...interface{}) (columns []string, types []string, result [][]interface{}, err error) {
78 var conn *sql.DB
79 if conn, err = s.getConn(dbID, true); err != nil {
80 return
81 }
82 defer conn.Close()
83
84 var tx *sql.Tx
85 if tx, err = conn.Begin(); err != nil {
86 return
87 }
88 defer tx.Rollback()
89
90 var rows *sql.Rows
91 if rows, err = tx.Query(query, args...); err != nil {
92 return
93 }
94 defer rows.Close()
95
96 if columns, err = rows.Columns(); err != nil {
97 return
98 }
99
100 var colTypes []*sql.ColumnType
101
102 if colTypes, err = rows.ColumnTypes(); err != nil {
103 return
104 }
105
106 types = make([]string, len(colTypes))
107
108 for i, c := range colTypes {
109 if c != nil {
110 types[i] = c.DatabaseTypeName()
111 }
112 }
113
114 result, err = readAllRows(rows)
115 return
116}
117
118// Exec implements the Storage abstraction interface.
119func (s *SQLite3Storage) Exec(dbID string, query string, args ...interface{}) (affectedRows int64, lastInsertID int64, err error) {

Callers

nothing calls this directly

Calls 7

getConnMethod · 0.95
readAllRowsFunction · 0.70
CloseMethod · 0.65
RollbackMethod · 0.65
QueryMethod · 0.65
BeginMethod · 0.45
ColumnsMethod · 0.45

Tested by

no test coverage detected