database

package
v0.0.0-...-91d8cf6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigQuery

type BigQuery struct {
	// contains filtered or unexported fields
}

BigQuery implements the Database interface for Google BigQuery

func NewBigQuery

func NewBigQuery(config *config.Config) (*BigQuery, error)

NewBigQuery creates a new BigQuery instance

func (*BigQuery) Close

func (b *BigQuery) Close()

Close closes the BigQuery connection

func (*BigQuery) Connect

func (b *BigQuery) Connect(ctx context.Context) error

Connect establishes a connection to BigQuery

func (*BigQuery) CreateDatabase

func (b *BigQuery) CreateDatabase() error

CreateDatabase creates the database if it doesn't exist

func (*BigQuery) DropDatabase

func (b *BigQuery) DropDatabase() error

DropDatabase drops the database if it exists

func (*BigQuery) Exec

func (b *BigQuery) Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

Exec executes a query without returning results

func (*BigQuery) ExtractBatch

func (b *BigQuery) ExtractBatch(table string, offset, limit int64, keyColumns, whereClause string) ([]map[string]interface{}, error)

ExtractBatch extracts a batch of rows from a table

func (*BigQuery) GetColumns

func (b *BigQuery) GetColumns(table string) ([]string, error)

GetColumns returns the columns of a table

func (*BigQuery) GetPrimaryKey

func (b *BigQuery) GetPrimaryKey(ctx context.Context, table string) (string, error)

GetPrimaryKey returns the primary key column of a table

func (*BigQuery) GetTableSchema

func (b *BigQuery) GetTableSchema(tableName string) ([]Column, error)

GetTableSchema returns the schema of a table

func (*BigQuery) GetTotalRows

func (b *BigQuery) GetTotalRows(table string) (int64, error)

GetTotalRows returns the total number of rows in a table

func (*BigQuery) Query

func (b *BigQuery) Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

Query executes a query and returns the results

type Column

type Column struct {
	Name     string
	Type     string
	Nullable bool
}

Column represents a database column

type Config

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  string
}

Config holds database connection configuration

type Database

type Database interface {
	// Connect establishes a connection to the database
	Connect(ctx context.Context) error

	// Close closes the database connection
	Close()

	// GetTableSchema returns the schema of a table
	GetTableSchema(tableName string) ([]Column, error)

	// Query executes a query and returns the results
	Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

	// Exec executes a query without returning results
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

	// GetTotalRows returns the total number of rows in a table
	GetTotalRows(ctx context.Context, table string) (int64, error)

	// GetColumns returns the columns of a table
	GetColumns(ctx context.Context, table string) ([]Column, error)

	// ExtractBatch extracts a batch of rows from a table
	ExtractBatch(ctx context.Context, table string, offset, limit int64) (Rows, error)

	// GetPrimaryKey returns the primary key column of a table
	GetPrimaryKey(ctx context.Context, table string) (string, error)

	// CreateDatabase creates the database if it doesn't exist
	CreateDatabase() error

	// DropDatabase drops the database if it exists
	DropDatabase() error
}

Database defines the interface for database operations

type Databricks

type Databricks struct {
	// contains filtered or unexported fields
}

Databricks implements the Database interface for Databricks

func NewDatabricks

func NewDatabricks(config *Config) *Databricks

NewDatabricks creates a new Databricks instance

func (*Databricks) Close

func (d *Databricks) Close()

Close closes the Databricks connection

func (*Databricks) Connect

func (d *Databricks) Connect(ctx context.Context) error

Connect establishes a connection to Databricks

func (*Databricks) CreateDatabase

func (d *Databricks) CreateDatabase() error

CreateDatabase creates the database if it doesn't exist

func (*Databricks) DropDatabase

func (d *Databricks) DropDatabase() error

DropDatabase drops the database if it exists

func (*Databricks) Exec

func (d *Databricks) Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

Exec executes a query without returning results

func (*Databricks) ExtractBatch

func (d *Databricks) ExtractBatch(ctx context.Context, table string, offset, limit int64) (Rows, error)

ExtractBatch extracts a batch of rows from a table

func (*Databricks) GetColumns

func (d *Databricks) GetColumns(ctx context.Context, table string) ([]Column, error)

GetColumns returns the columns of a table

func (*Databricks) GetPrimaryKey

func (d *Databricks) GetPrimaryKey(ctx context.Context, table string) (string, error)

GetPrimaryKey returns the primary key column of a table

func (*Databricks) GetTableSchema

func (d *Databricks) GetTableSchema(tableName string) ([]Column, error)

GetTableSchema returns the schema of a table

func (*Databricks) GetTotalRows

func (d *Databricks) GetTotalRows(ctx context.Context, table string) (int64, error)

GetTotalRows returns the total number of rows in a table

func (*Databricks) Query

func (d *Databricks) Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

Query executes a query and returns the results

type MSSQL

type MSSQL struct {
	// contains filtered or unexported fields
}

MSSQL implements the Database interface for Microsoft SQL Server

func NewMSSQL

func NewMSSQL(config *config.Config) *MSSQL

NewMSSQL creates a new SQL Server instance

func (*MSSQL) Close

func (m *MSSQL) Close()

Close closes the SQL Server connection

func (*MSSQL) Connect

func (m *MSSQL) Connect(ctx context.Context) error

Connect establishes a connection to SQL Server

func (*MSSQL) CreateDatabase

func (m *MSSQL) CreateDatabase() error

CreateDatabase creates the database if it doesn't exist

func (*MSSQL) DropDatabase

func (m *MSSQL) DropDatabase() error

DropDatabase drops the database if it exists

func (*MSSQL) Exec

func (m *MSSQL) Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

Exec executes a query without returning results

func (*MSSQL) ExtractBatch

func (m *MSSQL) ExtractBatch(table string, offset, limit int64, keyColumns, whereClause string) ([]map[string]interface{}, error)

ExtractBatch extracts a batch of rows from a table

func (*MSSQL) GetColumns

func (m *MSSQL) GetColumns(table string) ([]string, error)

GetColumns returns the columns of a table

func (*MSSQL) GetPrimaryKey

func (m *MSSQL) GetPrimaryKey(ctx context.Context, table string) (string, error)

GetPrimaryKey returns the primary key column of a table

func (*MSSQL) GetTableSchema

func (m *MSSQL) GetTableSchema(tableName string) ([]Column, error)

GetTableSchema returns the schema of a table

func (*MSSQL) GetTotalRows

func (m *MSSQL) GetTotalRows(table string) (int64, error)

GetTotalRows returns the total number of rows in a table

func (*MSSQL) Query

func (m *MSSQL) Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

Query executes a query and returns the results

type PostgresDB

type PostgresDB struct {
	// contains filtered or unexported fields
}

PostgresDB implements the Database interface for PostgreSQL

func NewPostgresDB

func NewPostgresDB(config *Config) *PostgresDB

NewPostgresDB creates a new PostgreSQL database instance

func (*PostgresDB) Close

func (p *PostgresDB) Close()

Close closes the database connection

func (*PostgresDB) Connect

func (p *PostgresDB) Connect(ctx context.Context) error

Connect establishes a connection to the PostgreSQL database

func (*PostgresDB) CreateDatabase

func (p *PostgresDB) CreateDatabase() error

CreateDatabase creates the database if it doesn't exist

func (*PostgresDB) DB

func (p *PostgresDB) DB() *sql.DB

DB returns the underlying database connection

func (*PostgresDB) DropDatabase

func (p *PostgresDB) DropDatabase() error

DropDatabase drops the database if it exists

func (*PostgresDB) Exec

func (p *PostgresDB) Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

Exec executes a query without returning results

func (*PostgresDB) ExtractBatch

func (p *PostgresDB) ExtractBatch(ctx context.Context, table string, offset, limit int64) (Rows, error)

ExtractBatch extracts a batch of rows from a table

func (*PostgresDB) GetColumns

func (p *PostgresDB) GetColumns(ctx context.Context, table string) ([]Column, error)

GetColumns returns the columns of a table

func (*PostgresDB) GetPrimaryKey

func (p *PostgresDB) GetPrimaryKey(ctx context.Context, table string) (string, error)

GetPrimaryKey returns the primary key column of a table

func (*PostgresDB) GetTableSchema

func (p *PostgresDB) GetTableSchema(tableName string) ([]Column, error)

GetTableSchema returns the schema of a table

func (*PostgresDB) GetTotalRows

func (p *PostgresDB) GetTotalRows(ctx context.Context, table string) (int64, error)

GetTotalRows returns the total number of rows in a table

func (*PostgresDB) Query

func (p *PostgresDB) Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

Query executes a query and returns the results

type Result

type Result interface {
	LastInsertId() (int64, error)
	RowsAffected() (int64, error)
}

Result represents the result of an Exec operation

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...interface{}) error
	Close() error
	Err() error
}

Rows represents a database result set

type Snowflake

type Snowflake struct {
	// contains filtered or unexported fields
}

Snowflake implements the Database interface for Snowflake

func NewSnowflake

func NewSnowflake(config *Config) *Snowflake

NewSnowflake creates a new Snowflake instance

func (*Snowflake) Close

func (s *Snowflake) Close()

Close closes the Snowflake connection

func (*Snowflake) Connect

func (s *Snowflake) Connect(ctx context.Context) error

Connect establishes a connection to Snowflake

func (*Snowflake) CreateDatabase

func (s *Snowflake) CreateDatabase() error

CreateDatabase creates the database if it doesn't exist

func (*Snowflake) DropDatabase

func (s *Snowflake) DropDatabase() error

DropDatabase drops the database if it exists

func (*Snowflake) Exec

func (s *Snowflake) Exec(ctx context.Context, query string, args ...interface{}) (Result, error)

Exec executes a query without returning results

func (*Snowflake) ExtractBatch

func (s *Snowflake) ExtractBatch(ctx context.Context, table string, offset, limit int64) (Rows, error)

ExtractBatch extracts a batch of rows from a table

func (*Snowflake) GetColumns

func (s *Snowflake) GetColumns(ctx context.Context, table string) ([]Column, error)

GetColumns returns the columns of a table

func (*Snowflake) GetPrimaryKey

func (s *Snowflake) GetPrimaryKey(ctx context.Context, table string) (string, error)

GetPrimaryKey returns the primary key column of a table

func (*Snowflake) GetTableSchema

func (s *Snowflake) GetTableSchema(tableName string) ([]Column, error)

GetTableSchema returns the schema of a table

func (*Snowflake) GetTotalRows

func (s *Snowflake) GetTotalRows(ctx context.Context, table string) (int64, error)

GetTotalRows returns the total number of rows in a table

func (*Snowflake) Query

func (s *Snowflake) Query(ctx context.Context, query string, args ...interface{}) (Rows, error)

Query executes a query and returns the results

Jump to

Keyboard shortcuts

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