db

package
v0.0.0-...-6b32d26 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 24

Documentation

Overview

Copyright 2021 SANGFOR TECHNOLOGIES

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.

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.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecDBWrite

func ExecDBWrite(f func() error) (err error)

ExecDBWrite backpressure database write

func ExecMultiSQL

func ExecMultiSQL(multiSQL *dtstruct.MultiSQL) (err error)

ExecMultiSQL exec multi sql in one transaction.

func ExecSQL

func ExecSQL(query string, args ...interface{}) (result sql.Result, err error)

ExecSQL will execute given sql on the backend database.

func GetDBClient

func GetDBClient() (db *sql.DB, err error)

GetDBClient get backend db client from cache or create it if not exist in cache.

func Query

func Query(query string, argsArray []interface{}, funcOnRow func(sqlutil.RowMap) error) (err error)

Query exec query and process result using function `funcOnRow`.

func QueryBuffered

func QueryBuffered(query string, argsArray []interface{}, funcOnRow func(sqlutil.RowMap) error) (err error)

QueryBuffered reads data from the database into a buffer, and only then applies the given function per row.

Types

type BackendDBHandler

type BackendDBHandler interface {

	// DBHandler get db client connected backend db to process crud, if err is not nil, db should be nil
	DBHandler() (db *sql.DB, err error)

	// CreateDatabase create database specified in config
	CreateDatabase() error

	// DeployCheck check if given version has already been deployed
	// return true means continue to deploy
	DeployCheck() (string, bool)

	// SchemaInit init all schema and apply patch ddl
	SchemaInit(schema []string)

	// StatementDialect refactor statement using dialect
	StatementDialect(statement string) (string, error)

	// Config config database using option param
	Config(option map[string]interface{})
}

BackendDBHandler interface to adapt different backend database

func GetBackendDBHandler

func GetBackendDBHandler(dbType string) BackendDBHandler

GetBackendDBHandler return backend db handler according to database type

Directories

Path Synopsis
Copyright 2021 SANGFOR TECHNOLOGIES
Copyright 2021 SANGFOR TECHNOLOGIES
mysql
Copyright 2021 SANGFOR TECHNOLOGIES
Copyright 2021 SANGFOR TECHNOLOGIES
sqlite
Copyright 2021 SANGFOR TECHNOLOGIES
Copyright 2021 SANGFOR TECHNOLOGIES
testdb
Copyright 2021 SANGFOR TECHNOLOGIES
Copyright 2021 SANGFOR TECHNOLOGIES
copyright 2017 shlomi noach, github inc.
copyright 2017 shlomi noach, github inc.

Jump to

Keyboard shortcuts

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