reader

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: BSD-3-Clause Imports: 11 Imported by: 1

README

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"
	"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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var URI_QUERYFUNC queryFunc
View Source
var URI_READFUNC readFunc
View Source
var VALID_KEY *regexp.Regexp
View Source
var VALID_TABLE *regexp.Regexp
View Source
var VALID_VALUE *regexp.Regexp

Functions

func NewSQLReader

func NewSQLReader(ctx context.Context, uri string) (wof_reader.Reader, error)

Types

type SQLReader

type SQLReader struct {
	wof_reader.Reader
	// contains filtered or unexported fields
}

func (*SQLReader) Read

func (r *SQLReader) Read(ctx context.Context, raw_uri string) (io.ReadSeekCloser, error)

func (*SQLReader) ReaderURI added in v0.1.0

func (r *SQLReader) ReaderURI(ctx context.Context, raw_uri string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL