schemata

package module
v0.0.0-...-7b01fc4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: BSD-2-Clause Imports: 13 Imported by: 0

README

Schemata: database scheme extractor & code generator in Go

Supported database:

  1. MySQL
  2. SQLite

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMySQLType

func ParseMySQLType(type_ string) reflect.Type

func ParseSQLiteType

func ParseSQLiteType(type_ string) reflect.Type

Types

type DB

type DB interface {
	ParseType(string) reflect.Type
}

type Field

type Field struct {
	Name     string       `json:"name"`
	GoName   string       `json:"go_name"`
	Primary  bool         `json:"primary,omitempty"`
	Nullable bool         `json:"nullable,omitemtpy"`
	Type     string       `json:"type"`
	GoType   reflect.Type `json:"go_type"`
}

type Fields

type Fields []Field

func (Fields) Select

func (fs Fields) Select(w io.Writer)

func (Fields) ToList

func (fs Fields) ToList(w io.Writer)

type GoType

type GoType struct {
	reflect.Type
}

func (*GoType) MarshalText

func (t *GoType) MarshalText() (text []byte, err error)

func (*GoType) UnmarshalText

func (t *GoType) UnmarshalText(text []byte) error

type MySQL

type MySQL struct {
	DB *sql.DB
}

func (MySQL) Schema

func (d MySQL) Schema(source string) (*Schema, error)

type SQLite

type SQLite struct {
	DB *sql.DB
}

func (SQLite) Schema

func (d SQLite) Schema(source string) (*Schema, error)

type Schema

type Schema struct {
	Name       string `json:"name"`
	GoName     string `json:"go_name"`
	Fields     Fields `json:"fields"`
	FromSelect bool   `json:"from_select"`
	DB         string `json:"db"`
}

func LoadSchema

func LoadSchema(file string) (*Schema, error)

func (*Schema) InsertIgnoreQuery

func (s *Schema) InsertIgnoreQuery(w io.Writer)

func (*Schema) InsertQuery

func (s *Schema) InsertQuery(w io.Writer)

func (*Schema) JSON

func (s *Schema) JSON(w io.Writer)

func (*Schema) Scan

func (s *Schema) Scan(w io.Writer, name string)

func (*Schema) Select

func (s *Schema) Select(w io.Writer)

func (*Schema) String

func (s *Schema) String() string

func (*Schema) Struct

func (s *Schema) Struct(tags ...string) *gengo.TypeDecl

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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