func (sqlite SqliteDialecter) Table(db *sql.DB, name string) (table *ansi.DbTable, err error) {
	query := fmt.Sprintf(`SELECT name, type FROM sqlite_master WHERE name = '%s'; `, name)
	var rows *sql.Rows
	if rows, err = db.Query(query); err != nil {
		return
	}
	var t *ansi.DbTable
	for rows.Next() {
		tt := ansi.NewTable()
		if err = rows.Scan(&tt.Name, &tt.Type); err != nil {
		} else {
			t = tt
		}
	}
	if err = rows.Err(); err != nil {
		return
	}
	if t == nil {
		err = errors.New("table doesn't exist:" + name)
		return
	}
	query = fmt.Sprintf("PRAGMA table_info(%s)", t.Name)
	if rows, err = db.Query(query); err != nil {
		return
	}
	for rows.Next() {
		col := ansi.DbColumn{}
		var dflt sql.NullString
		if err = rows.Scan(&col.Position, &col.Name, &col.NativeType, &col.IsNullable, &dflt, &col.IsPrimaryKey); err != nil {
		} else {
			col.DbType = sqlite.DbType(col.NativeType)
			col.IsNullable = col.IsNullable == false
			t.Columns = append(t.Columns, col)
		}
	}
	if err = rows.Err(); err != nil {
		return
	}
	table = t
	return
}
Table return schema of table,view
package kdb
import (
	"bytes"
	"database/sql"
	"errors"
	"fmt"
	"github.com/sdming/kdb/ansi"
	"reflect"
	"strconv"
	"strings"
)
type Driver interface {
	Compiler
}
type Compiler interface {
	Compile(source string, exp Expression) (query string, args []interface{}, err error)
}
var _compilers = make(map[string]Compiler)
func RegisterCompiler(driver string, compiler Compiler) {
	if compiler == nil {
		panic("register compiler is nil")
	}
	_compilers[driver] = compiler
}
func GetCompiler(driver string) (Compiler, error) {
	c, ok := _compilers[driver]
	if !ok {
		return nil, errors.New(fmt.Sprint("can not get compiler:", driver))
	}
	return c, nil
}
type Schemaer interface {
	Table(db *sql.DB, name string) (*ansi.DbTable, error)
	Function(db *sql.DB, name string) (*ansi.DbFunction, error)
}
var _schemaers = make(map[string]Schemaer)
func RegisterSchemaer(driver string, schemaer Schemaer) {
	if schemaer == nil {
		panic("register schemaer is nil")
	}
	_schemaers[driver] = schemaer
}
func GetSchemaer(driver string) (Schemaer, error) {
	schema, ok := _schemaers[driver]
	if !ok {
		return nil, errors.New(fmt.Sprint("can not get schemaer:", driver))
	}
	return schema, nil
}
type Dialecter interface {
	Name() string
	SupportNamedParameter() bool
	SupportIndexedParameter() bool
	ParameterPlaceHolder() string
	QuoteString(s string) string
	Quote(string) string
	TableSql(name string) string
	ColumnsSql(name string) string
	FunctionSql(name string) string
	ParametersSql(name string) string
	DbType(nativeType string) ansi.DbType
	SplitStatement() string
}
var _dialecters = make(map[string]Dialecter)
func RegisterDialecter(driver string, dialecter Dialecter) {
	if dialecter == nil {
		panic("register dialecter is nil")
	}
	_dialecters[driver] = dialecter
}
func GetDialecter(driver string) (Dialecter, error) {
	d, ok := _dialecters[driver]
	if !ok {
		return nil, errors.New(fmt.Sprint("can not get dialecter:", driver))
	}
	return d, nil
}
func DefaultDialecter() Dialecter {
	return AnsiDialecter{}
}
type AnsiDialecter struct {
}
func (ad AnsiDialecter) Name() string {
	return "ansi"
}
func (ad AnsiDialecter) SupportNamedParameter() bool {
	return false
}
func (ad AnsiDialecter) SupportIndexedParameter() bool {
	return false
}
func (ad AnsiDialecter) ParameterPlaceHolder() string {
	return " ? "
}
func (ad AnsiDialecter) QuoteString(s string) string {
	return "'" + s + "'"
}
func (ad AnsiDialecter) Quote(s string) string {
	return "\"" + s + "\""
}
func (ansi AnsiDialecter) TableSql(name string) string {
	return ""
}
func (ansi AnsiDialecter) ColumnsSql(name string) string {
	return ""
}
func (ad AnsiDialecter) FunctionSql(s string) string {
	return ""
}
func (ad AnsiDialecter) ParametersSql(name string) string {
	return ""
}
func (ad AnsiDialecter) SplitStatement() string {
	return " ; "
}
func (ad AnsiDialecter) DbType(nativeType string) ansi.DbType {
	switch strings.ToLower(nativeType) {
	case "xml", "tinytext", "mediumtext", "longtext", "ntext", "text", "sysname", "sql_variant", "note", "memo", "clob":
		return ansi.String
	case "char", "character", "nchar", "varchar", "nvarchar", "string", "longvarchar", "longchar", "varyingcharacter":
		return ansi.String
	case "nativecharacter", "native character", "nativevaryingcharacter", "character varying":
		return ansi.String
	case "bit", "bool", "boolean", "yesno", "logical":
		return ansi.Boolean
	case "tinyint unsigned", "uint16", "smallint unsigned", "uint32", "integer unsigned", "uint64", "bigint unsigned", "unsigned, bigint", "int2", "int8":
		return ansi.Int
	case "tinyint", "smallint", "int", "mediumint", "bigint", "int16", "int32", "int64", "integer", "long":
		return ansi.Int
	case "bigserial", "serial", "smallserial":
		return ansi.Int
	case "identity", "counter", "autoincrement":
		return ansi.Int
	case "decimal", "newdecimal", "numeric":
		return ansi.Numeric
	case "currency", "money", "smallmoney":
		return ansi.Numeric
	case "float", "real", "double", "double precision":
		return ansi.Float
	case "date", "smalldate":
		return ansi.Date
	case "time", "datetime", "datetime2", "smalldatetime", "timestamp", "timestamp without time zone", "timestamp with time zone":
		return ansi.DateTime
	case "year":
		return ansi.Int
	case "image", "varbinary", "binary", "blob", "tinyblob", "mediumblob", "longblob", "oleobject", "general", "bit varying", "bytea":
		return ansi.Bytes
	case "uniqueidentifier", "guid", "uuid":
		return ansi.Guid
	default:
		return ansi.Var
	}
	return ansi.Var
}
type SqliteDialecter struct {
	AnsiDialecter
}
func (sqlite SqliteDialecter) Name() string {
	return "sqlite"
}