Documentation ¶
Overview ¶
Package database ...
Copyright © 2019 hajime-terasawa <terako.studio@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package database ...
Copyright © 2019 hajime-terasawa <terako.studio@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func SetupMySQLDB(cfg *config.Database) error
- type DBClient
- type MySQLClient
- func (db *MySQLClient) BuildCreateTableStmt(cfg *config.Table) string
- func (db *MySQLClient) BuildDefaultDesc(cfg *config.Column) string
- func (db *MySQLClient) BuildDropTableStmt(cfg *config.Table) string
- func (db *MySQLClient) BuildIndexDesc(cfg *config.Index) string
- func (db *MySQLClient) BuildInsertStmt(cfg *config.Table, values []string) string
- func (db *MySQLClient) CreateTable(cfg *config.Table) error
- func (db *MySQLClient) DropTable(cfg *config.Table) error
- func (db *MySQLClient) Populate(cfg *config.Table) error
Constants ¶
This section is empty.
Variables ¶
var IncrementableDataType = []interface{}{
"tinyint",
"smallint",
"mediumint",
"int",
"bigint",
}
IncrementableDataType accepts increment options
var MaxConnections int
MaxConnections holds max_connections var for memory use control
var OrderRequiredDataTypes = []interface{}{
"tinyint",
"smallint",
"mediumint",
"int",
"bigint",
"bit",
"blob",
"text",
"year",
"char",
"varchar",
"binary",
"varbinary",
}
OrderRequiredDataTypes require DataType(Order) like sql
var PrecisionRequiredDataTypes = []interface{}{
"decimal",
"float",
"real",
"double",
}
PrecisionRequiredDataTypes require DataType(Order, Precision) like sql
var ProhibitDefaultDataTypes = []interface{}{
"tinyblob",
"tinytext",
"blob",
"text",
"mediumblob",
"mediumtext",
"longblob",
"longtext",
}
ProhibitDefaultDataTypes must allow null value
var UnsignedableDataType = []interface{}{
"tinyint",
"smallint",
"mediumint",
"int",
"bigint",
"decimal",
"float",
"real",
"double",
}
UnsignedableDataType accepts unsigned options
var Verbose bool
Verbose displays sql from cobra
Functions ¶
func SetupMySQLDB ¶
SetupMySQLDB find_or_create database w/ given database name, then connect it
Types ¶
type DBClient ¶
type DBClient interface { CreateTable(cfg *config.Table) error DropTable(cfg *config.Table) error Populate(cfg *config.Table) error }
DBClient is an interface for DB Querying
func BuildClient ¶
BuildClient builds DBClient for abstraction
type MySQLClient ¶
MySQLClient is an implementation of DBClient for MySQL
func BuildMySQLClient ¶
func BuildMySQLClient(cfg *config.Database) (*MySQLClient, error)
BuildMySQLClient returns MySQLClient
func (*MySQLClient) BuildCreateTableStmt ¶
func (db *MySQLClient) BuildCreateTableStmt(cfg *config.Table) string
BuildCreateTableStmt generate create_table_stmt sql for MySQL
func (*MySQLClient) BuildDefaultDesc ¶
func (db *MySQLClient) BuildDefaultDesc(cfg *config.Column) string
BuildDefaultDesc generate a default desc part of sql for MySQL
func (*MySQLClient) BuildDropTableStmt ¶
func (db *MySQLClient) BuildDropTableStmt(cfg *config.Table) string
BuildDropTableStmt generate drop_table_stmt sql for MySQL
func (*MySQLClient) BuildIndexDesc ¶
func (db *MySQLClient) BuildIndexDesc(cfg *config.Index) string
BuildIndexDesc generate an index desc part of sql for MySQL
func (*MySQLClient) BuildInsertStmt ¶
func (db *MySQLClient) BuildInsertStmt(cfg *config.Table, values []string) string
BuildInsertStmt generate insert_stmt sql for MySQL
func (*MySQLClient) CreateTable ¶
func (db *MySQLClient) CreateTable(cfg *config.Table) error
CreateTable does CreateTable statement for MySQL