sqlite3

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapSQLiteType

func MapSQLiteType(t string) (*schema.FieldType, error)

func ParseTableSQL

func ParseTableSQL(tableSQL string) (*schema.Table, error)

Types

type Driver

type Driver struct {
	DataSource string
}

func (*Driver) ReadTables

func (d *Driver) ReadTables() ([]*schema.Table, error)

type SQLiteCheck added in v0.1.5

type SQLiteCheck struct {
	Name   string `parser:"@Ident"`
	Values []int  `parser:"'IN' '(' @Number ',' @Number ')'"`
}

type SQLiteConstraint

type SQLiteConstraint struct {
	Name            string `parser:"@Ident"`
	Key             string `parser:"('FOREIGN' | 'PRIMARY') 'KEY' '(' @Ident ')'"`
	ReferencedTable string `parser:"('REFERENCES' @Ident)?"`
	ReferencedField string `parser:"('(' @Ident ')')?"`
}

type SQLiteCreateTable

type SQLiteCreateTable struct {
	TableName        string                   `parser:"'CREATE' 'TABLE' ( 'IF' 'NOT' 'EXISTS' )? @Ident"`
	FieldExpressions []*SQLiteFieldExpression `parser:"'(' @@ ( ',' @@ )* ( ',' )?"`
	PrimaryKeys      []string                 `parser:"( 'PRIMARY' 'KEY' '(' @Ident ( ',' @Ident )* ')' ( ',' )? )?"`
	ForeignKeys      []*SQLiteForeignKey      `parser:"( 'FOREIGN' 'KEY' @@ ( ',' 'FOREIGN' 'KEY' @@ )* ( ',' )? )?"`
	Constraints      []*SQLiteConstraint      `parser:"( 'CONSTRAINT' @@ ( ',' 'CONSTRAINT' @@ )* ( ',' )? )?"`
	Checks           []*SQLiteCheck           `parser:"( 'CHECK' '(' @@ ')' ( ',' 'CHECK' '(' @@ ')' )* )? ')'"`
}

type SQLiteFieldExpression

type SQLiteFieldExpression struct {
	Name          string `parser:"@Ident"`
	Type          string `parser:"@Ident"`
	Limit         string `parser:"( '(' Number ')' )?"`
	NotNull       bool   `parser:"( @'NOT' 'NULL' | @'NOT_NULL'"`
	Default       string `parser:"| 'DEFAULT' '(' @Ident ')'"`
	AutoIncrement bool   `parser:"| @'AUTO_INCREMENT' )*"`
}

type SQLiteForeignKey added in v0.1.5

type SQLiteForeignKey struct {
	ForeignKey      string `parser:"'(' @Ident ')'"`
	ReferencedTable string `parser:"'REFERENCES' @Ident"`
	ReferencedField string `parser:"'(' @Ident ')'"`
}

type SQLiteTable

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

func SelectTables

func SelectTables(conn *sql.DB) ([]*SQLiteTable, error)

Jump to

Keyboard shortcuts

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