https://github.com/whosonfirst/go-reader-database-sql
database/sql support for the go-reader Reader interface.
https://github.com/whosonfirst/go-reader-database-sql
golang whosonfirst whosonfirst-reader
Last synced: 5 months ago
JSON representation
database/sql support for the go-reader Reader interface.
- Host: GitHub
- URL: https://github.com/whosonfirst/go-reader-database-sql
- Owner: whosonfirst
- License: bsd-3-clause
- Created: 2019-12-15T02:50:02.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-12T03:12:55.000Z (6 months ago)
- Last Synced: 2024-12-12T04:20:15.691Z (6 months ago)
- Topics: golang, whosonfirst, whosonfirst-reader
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-reader-database-sql
[database/sql](https://golang.org/pkg/database/sql/) support for the go-reader Reader interface.
## Important
Work in progress. Documentation to follow.
## Example
```
package mainimport (
"context"
"io"
"os"
"strconv""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"
)func main() {
ctx := context.Background()// You can also enable this specific "read function" by passing
// ?parse-uri=true to the reader URI below.
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
* https://github.com/whosonfirst/go-reader
* https://golang.org/pkg/database/sql/