/go-reader-database-sql

database/sql support for the go-reader Reader interface.

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

go-reader-database-sql

database/sql support for the go-reader Reader interface.

Important

Work in progress. Documentation to follow.

Example

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)		
}

See also