database/sql support for the go-reader Reader interface.
Work in progress. Documentation to follow.
package main
import (
"context"
"github.com/whosonfirst/go-reader"
wof_uri "github.com/whosonfirst/go-whosonfirst-uri"
sql_reader "github.com/whosonfirst/go-reader-database-sql"
_ "github.com/mattn/go-sqlite3"
"io"
"os"
"strconv"
)
func main() {
ctx := context.Background()
sql_reader.URI_READFUNC = func(uri string) (string, error) {
id, _ := wof_uri.IdFromPath(uri)
str_id := strconv.FormatInt(id, 10)
return str_id, nil
}
uri := "sql://sqlite3/geojson/id/body?dsn=fr.db"
r, _ := reader.NewReader(ctx, uri)
fh, _ := r.Read(ctx, "102/065/003/102065003.geojson")
defer fh.Close()
io.Copy(os.Stdout, fh)
}