driver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package driver provides file SQL driver implementation. This package implements database/sql/driver interfaces to enable reading CSV, TSV, and LTSV files as SQL databases through SQLite3.

Package driver provides file SQL driver implementation for database/sql.

This package implements a database/sql driver that allows querying CSV, TSV, and LTSV files (including compressed versions) as if they were SQL tables. Files are loaded into an in-memory SQLite database for query execution.

Key features:

  • Support for CSV, TSV, and LTSV file formats
  • Support for compressed files (gzip, bzip2, xz, zstd)
  • Duplicate table name validation across multiple files
  • Directory scanning with automatic file discovery
  • Table export functionality

Usage:

import _ "github.com/nao1215/filesql/driver"
db, err := sql.Open("filesql", "data.csv")

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPathsProvided is returned when no paths are provided
	ErrNoPathsProvided = errors.New("filesql driver: no paths provided")

	// ErrNoFilesLoaded is returned when no files were loaded
	ErrNoFilesLoaded = errors.New("filesql driver: no files were loaded")

	// ErrStmtExecContextNotSupported is returned when statement does not support ExecContext
	ErrStmtExecContextNotSupported = errors.New("filesql driver: statement does not support ExecContext")

	// ErrBeginTxNotSupported is returned when underlying connection does not support BeginTx
	ErrBeginTxNotSupported = errors.New("filesql driver: underlying connection does not support BeginTx")

	// ErrPrepareContextNotSupported is returned when underlying connection does not support PrepareContext
	ErrPrepareContextNotSupported = errors.New("filesql driver: underlying connection does not support PrepareContext")

	// ErrNotFilesqlConnection is returned when connection is not a filesql connection
	ErrNotFilesqlConnection = errors.New("filesql driver: connection is not a filesql connection")

	// ErrDuplicateColumnName is returned when a file contains duplicate column names
	ErrDuplicateColumnName = errors.New("filesql driver: duplicate column name")

	// ErrDuplicateTableName is returned when multiple files would create the same table name
	ErrDuplicateTableName = errors.New("filesql driver: duplicate table name")
)

Predefined errors

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection implements database/sql/driver.Conn interface. It wraps an underlying SQLite connection that contains loaded file data.

func (*Connection) Begin

func (conn *Connection) Begin() (driver.Tx, error)

Begin implements driver.Conn interface (deprecated, use BeginTx instead)

func (*Connection) BeginTx

func (conn *Connection) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx implements driver.ConnBeginTx interface

func (*Connection) Close

func (conn *Connection) Close() error

Close implements driver.Conn interface

func (*Connection) Dump

func (conn *Connection) Dump(outputDir string) error

Dump exports all tables from SQLite3 database to specified directory in CSV format

func (*Connection) DumpWithOptions added in v0.0.4

func (conn *Connection) DumpWithOptions(outputDir string, options model.DumpOptions) error

DumpWithOptions exports all tables from SQLite3 database to specified directory with given options

func (*Connection) Prepare

func (conn *Connection) Prepare(query string) (driver.Stmt, error)

Prepare implements driver.Conn interface (deprecated, use PrepareContext instead)

func (*Connection) PrepareContext

func (conn *Connection) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext implements driver.ConnPrepareContext interface

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector implements database/sql/driver.Connector interface. It holds connection parameters and manages the creation of database connections. The dsn field contains file paths separated by semicolons for multiple files.

func (*Connector) Connect

func (c *Connector) Connect(_ context.Context) (driver.Conn, error)

Connect implements driver.Connector interface

func (*Connector) Driver

func (c *Connector) Driver() driver.Driver

Driver implements driver.Connector interface

type Driver

type Driver struct{}

Driver implements database/sql/driver.Driver interface for file-based SQL. It serves as the entry point for creating connections to file-based databases.

func NewDriver

func NewDriver() *Driver

NewDriver creates a new file SQL driver

func (*Driver) Open

func (d *Driver) Open(dsn string) (driver.Conn, error)

Open implements driver.Driver interface

func (*Driver) OpenConnector

func (d *Driver) OpenConnector(dsn string) (driver.Connector, error)

OpenConnector implements driver.DriverContext interface

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction implements database/sql/driver.Tx interface. It wraps an underlying SQLite transaction for atomic operations.

func (*Transaction) Commit

func (t *Transaction) Commit() error

Commit implements driver.Tx interface

func (*Transaction) Rollback

func (t *Transaction) Rollback() error

Rollback implements driver.Tx interface

Jump to

Keyboard shortcuts

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