rothgar / gosqlite

Automatically exported from code.google.com/p/gosqlite
0 stars 0 forks source link

Return output of SQL statement #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This function should be added since it's very usefull to get the output of a 
SQL statement.

* * *
func (c *Conn) QueryOutput(statement string) (a []string, err os.Error) {
    query, err := c.Prepare(statement)
    if err != nil {
        return
    }
    defer query.Finalize()

    if err = query.Exec(); err != nil {
        return
    }

    var field string

    for {
        if ok := query.Next(); !ok {
            break
        }

        if err = query.Scan(&field); err != nil {
            return nil, err
        }
        a = append(a, field)
    }

    return
}
* * *

Original issue reported on code.google.com by raul....@sent.com on 1 Dec 2010 at 12:06

GoogleCodeExporter commented 8 years ago
It's better into a generic interface to databases. Please, close this issue.

Original comment by raul....@sent.com on 9 Dec 2010 at 6:04