diff --git a/sqlite3.go b/sqlite3.go index d645af1..1a93298 100644 --- a/sqlite3.go +++ b/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))