Implements Queryer
This commit is contained in:
parent
132e6e9898
commit
3f20cb1697
25
sqlite3.go
25
sqlite3.go
|
@ -137,7 +137,6 @@ func (c *SQLiteConn) AutoCommit() bool {
|
|||
// Implements Execer
|
||||
func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error) {
|
||||
for {
|
||||
println(query)
|
||||
ds, err := c.Prepare(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -158,6 +157,30 @@ func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, err
|
|||
}
|
||||
}
|
||||
|
||||
// Implements Queryer
|
||||
func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error) {
|
||||
for {
|
||||
ds, err := c.Prepare(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s := ds.(*SQLiteStmt)
|
||||
na := s.NumInput()
|
||||
rows, err := s.Query(args[:na])
|
||||
args = args[na:]
|
||||
s.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s.t == "" {
|
||||
return rows, nil
|
||||
}
|
||||
rows.Close()
|
||||
s.Close()
|
||||
query = s.t
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SQLiteConn) exec(cmd string) error {
|
||||
pcmd := C.CString(cmd)
|
||||
defer C.free(unsafe.Pointer(pcmd))
|
||||
|
|
Loading…
Reference in New Issue