database

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDatabaseName

func GetDatabaseName(datasource string) (string, error)

GetDatabaseName parse the database name (or MaxCompute project) from the database connection string

func GetSessionFromTestingDB

func GetSessionFromTestingDB() *proto.Session

GetSessionFromTestingDB construct a proto message Session representing the testing database configuration.

func GetTestingHiveURL added in v0.4.2

func GetTestingHiveURL() string

GetTestingHiveURL reutrns Hive connection URL

func GetTestingMySQLConfig

func GetTestingMySQLConfig() *mysql.Config

GetTestingMySQLConfig construct a MySQL config

func GetTestingMySQLURL

func GetTestingMySQLURL() string

GetTestingMySQLURL returns MySQL connection URL

func ParseURL

func ParseURL(url string) (string, string, error)

ParseURL splits the URL into Drivername and DataSourceName.

Types

type DB

type DB struct {
	DriverName     string // NOTE: Don't name it Driver, because Driver is a method of sql.DB.
	DataSourceName string
	*sql.DB
}

DB extends sql.DB, while keeping the two parameters, DriverName and DataSource, to database/sql.Open reaccessible.

func GetTestingDBSingleton

func GetTestingDBSingleton() *DB

GetTestingDBSingleton returns the testing DB singleton.

func OpenAndConnectDB

func OpenAndConnectDB(url string) (*DB, error)

OpenAndConnectDB calls OpenDB to open a database specified by an URL. In addition to opening, it also call database.DB.Ping to ensure a connection to the database.

func OpenDB

func OpenDB(url string) (*DB, error)

OpenDB open a database identified by an URL. It calls ParseURL to get the driver and data source name. In addition to opening the database, it also verifies the driver is loaded.

func (*DB) URL

func (db *DB) URL() string

URL calls unparseURL to build the URL from DriverName and DataSourceName.

Jump to

Keyboard shortcuts

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