Documentation
¶
Overview ¶
Package sqlrows reads a database/sql result into a batch: Polars' read_database (step 353). A column's type is its values', their kinds met as Polars meets the values of a column it builds from rows, and then the type its driver names it, where every value fits that type.
Index ¶
- func Read(rows *sql.Rows, o Options) (*data.Batch, error)
- type Dialect
- func (d Dialect) ColumnType(t dtype.DataType) (string, error)
- func (d Dialect) CreateTable(table string, s *dtype.Schema) (string, error)
- func (d Dialect) DropTable(table string) string
- func (d Dialect) Exists(table string) (string, []any)
- func (d Dialect) Insert(table string, cols []string, rows int) string
- func (d Dialect) Placeholder(n int) string
- func (d Dialect) Quote(name string) string
- func (d Dialect) RowsPerInsert(width int) int
- func (d Dialect) String() string
- func (d Dialect) Table(name string) string
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dialect ¶ added in v0.6.8
type Dialect int
Dialect is how a SQL database spells what a write says to it (step 366): its placeholders, its quoting, its columns' types and its limits. database/sql cannot name it, so a caller names it, or the driver's package does.
func DialectOf ¶ added in v0.6.8
DialectOf names the dialect of a database/sql driver, or of a driver connection, by its package: modernc's and mattn's SQLite, pgx's and lib/pq's PostgreSQL, the MySQL driver, and Microsoft's and denisenkom's SQL Server.
func (Dialect) ColumnType ¶ added in v0.6.8
ColumnType is the type a column of t is created as, the one ReadDatabase reads back as t where the database keeps it. A List, an Array, a Struct and a Duration have none, and are refused by name.
func (Dialect) CreateTable ¶ added in v0.6.8
CreateTable is the statement that creates table with the columns of s.
func (Dialect) Exists ¶ added in v0.6.8
Exists is a query of one row and one value, nonzero or true when table exists, and its arguments: SQLite's catalogue, PostgreSQL's to_regclass, MySQL's information_schema, SQL Server's OBJECT_ID. Each finds the table as a statement naming it would, in the schema the name gives or the connection's own.
func (Dialect) Placeholder ¶ added in v0.6.8
Placeholder is the nth parameter's marker, from 1.
func (Dialect) Quote ¶ added in v0.6.8
Quote is name as one identifier: in double quotes, as the standard and SQLite and PostgreSQL quote it, in backquotes for MySQL, in brackets for SQL Server, each doubling its closing quote within.
func (Dialect) RowsPerInsert ¶ added in v0.6.8
RowsPerInsert is how many rows of width columns one INSERT takes: as many as its parameters allow, at most a thousand, the most SQL Server takes in one VALUES. SQLite's are 999, the least any of its builds allows; SQL Server's 2,100 a statement.