hi there,
(apologies for the flood...)
I have the following code:
``` go
import (
"database/sql"
_ "
github.com/ziutek/mymysql/godrv"
)
func buildAndRunQuery(verbose bool) error {
db, err := sql.Open("mymysql", "<phone home>")
handleErr(err)
query := []string{}
args := []interface{}{}
// somehow build a query depending on the phase of the moon and
// other interesting values
query = append(query, "select data from sometable where")
if g_moon == 42 {
query = append(query, "date>? and date<?")
args = append(args, date_begin, date_end)
}
if g_hell == 666 {
// ...
}
if verbose {
fmt.Printf("%s\n", strings.Join(query, " "))
}
rows, err := db.Query(strings.Join(query, " "), args...)
handleErr(err)
err = doStuff(rows)
return err
}
```
is there a way to print the query with the '?' placeholders holding
their actual value, ie, as the sql driver will see it ?
or should I just replace '?' with '%v' and Sprintf the resulting
query-string together with the args... slice ?
-s