Documentation ¶
Index ¶
- Constants
- func ConnectToBigQuery(config BigQueryConfig) (*bigquery.Client, error)
- func ConnectToPostgres(config PostgresConnectionConfig) (*sql.DB, error)
- func DisconnectFromDatabase(databaseType string, connection DatabaseConnection) error
- func DisconnectFromPostgres(db *sql.DB) error
- func GetColumnInfoBySchemaByDatabase(databaseType string, connection DatabaseConnection, tables []Table) (interface{}, error)
- func GetColumnsByTableBigQuery(client *bigquery.Client, schemaName, tableName string) ([]string, error)
- func GetColumnsByTableByDatabase(ctx context.Context, databaseType string, connection DatabaseConnection, ...) ([]string, error)
- func GetColumnsByTablePostgres(db *sql.DB, schemaName, tableName string) ([]string, error)
- func GetDatabaseCredentials(databaseType, connectionString string) (interface{}, error)
- func GetForeignKeysBigQuery(connection *bigquery.Client, schemaName, tableName, primaryKey string) ([]string, error)
- func GetForeignKeysByDatabase(ctx context.Context, databaseType string, connection DatabaseConnection, ...) ([]string, error)
- func GetForeignKeysPostgres(db *sql.DB, schemaName, tableName, primaryKey string) ([]string, error)
- func GetSchemaBigQuery(client *bigquery.Client) ([]string, error)
- func GetSchemaColumnInfoPostgres(db *sql.DB, tableNames []Table) ([]map[string]interface{}, error)
- func GetSchemasByDatabase(databaseType string, connection DatabaseConnection) ([]string, error)
- func GetSchemasPostgres(db *sql.DB) ([]string, error)
- func MapQueries(queries []string, targetConnection *CachedConnection) ([]map[string]interface{}, error)
- type BigQueryConfig
- type CachedConnection
- type ColumnInfo
- type DatabaseConnection
- type Field
- type PostgresConnectionConfig
- type QueryResults
- type RedisCache
- type Table
- func GetTablesBySchemaBigQuery(client *bigquery.Client, schemaNames []string) ([]Table, error)
- func GetTablesBySchemaByDatabase(databaseType string, connection DatabaseConnection, schemaName interface{}) ([]Table, error)
- func GetTablesBySchemaPostgres(db *sql.DB, schemaNames []string) ([]Table, error)
- type TableColumnInfo
Constants ¶
const DEFAULT_CACHE_TTL time.Duration = 24 * 60 * 60
DEFAULT_CACHE_TTL is the default TTL for new cache entries (24 hours)
Variables ¶
This section is empty.
Functions ¶
func ConnectToBigQuery ¶
func ConnectToBigQuery(config BigQueryConfig) (*bigquery.Client, error)
func ConnectToPostgres ¶
func ConnectToPostgres(config PostgresConnectionConfig) (*sql.DB, error)
ConnectToPostgres establishes a connection to a PostgreSQL database.
func DisconnectFromDatabase ¶
func DisconnectFromDatabase(databaseType string, connection DatabaseConnection) error
func DisconnectFromPostgres ¶
DisconnectFromPostgres closes the connection to the PostgreSQL database.
func GetColumnInfoBySchemaByDatabase ¶
func GetColumnInfoBySchemaByDatabase( databaseType string, connection DatabaseConnection, tables []Table, ) (interface{}, error)
func GetColumnsByTablePostgres ¶
GetColumnsByTablePostgres retrieves the columns for a given table from the PostgreSQL database.
func GetDatabaseCredentials ¶
func GetForeignKeysBigQuery ¶
func GetForeignKeysPostgres ¶
GetForeignKeysPostgres retrieves the foreign keys for a given table from the PostgreSQL database.
func GetSchemaColumnInfoPostgres ¶
GetSchemaColumnInfoPostgres retrieves column information for a given schema from the PostgreSQL database.
func GetSchemasByDatabase ¶
func GetSchemasByDatabase(databaseType string, connection DatabaseConnection) ([]string, error)
func GetSchemasPostgres ¶
GetSchemasPostgres retrieves the list of schemas from the PostgreSQL database.
func MapQueries ¶
func MapQueries(queries []string, targetConnection *CachedConnection) ([]map[string]interface{}, error)
Types ¶
type BigQueryConfig ¶
type BigQueryConfig struct { DatasetName string ProjectID string Credentials map[string]interface{} }
func FormatBigQueryConfig ¶
func FormatBigQueryConfig(connectionString string) (BigQueryConfig, error)
type CachedConnection ¶
type CachedConnection struct { DatabaseType string Pool DatabaseConnection OrgID interface{} TTL time.Duration Cache models.RedisMapable }
CachedConnection represents a cached database connection
func NewCachedConnection ¶
func NewCachedConnection(databaseType string, config interface{}, cacheConfig models.CacheCredentials) (*CachedConnection, error)
NewCachedConnection creates a new CachedConnection
func (*CachedConnection) Close ¶
func (c *CachedConnection) Close() error
Close closes the database connection
func (*CachedConnection) Query ¶
func (c *CachedConnection) Query(text string) (interface{}, error)
Query executes a query and caches the result
type ColumnInfo ¶
type DatabaseConnection ¶
type DatabaseConnection interface{} // TODO: Define this type
func ConnectToDatabase ¶
func ConnectToDatabase(databaseType string, config interface{}) (DatabaseConnection, error)
type PostgresConnectionConfig ¶
type PostgresConnectionConfig struct { ConnectionString string SSL *struct { RejectUnauthorized bool CA *string Key *string Cert *string } }
func FormatPostgresConfig ¶
func FormatPostgresConfig(connectionString string) (PostgresConnectionConfig, error)
type QueryResults ¶
type QueryResults struct { Fields []Field `json:"fields"` Rows []map[string]interface{} `json:"rows"` }
func RunQueryBigQuery ¶
func RunQueryBigQuery(client *bigquery.Client, sql string) (*QueryResults, error)
func RunQueryByDatabase ¶
func RunQueryByDatabase(databaseType string, connection DatabaseConnection, query string) (*QueryResults, error)
func RunQueryPostgres ¶
func RunQueryPostgres(db *sql.DB, query string) (*QueryResults, error)
RunQueryPostgres executes a SQL query on the PostgreSQL database.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is a wrapper around *redis.Client that implements the Mapable interface
type Table ¶
func GetTablesBySchemaByDatabase ¶
func GetTablesBySchemaByDatabase( databaseType string, connection DatabaseConnection, schemaName interface{}, ) ([]Table, error)
type TableColumnInfo ¶
type TableColumnInfo struct { TableName string DisplayName string Columns []ColumnInfo }
func GetSchemaColumnInfoBigQuery ¶
func GetSchemaColumnInfoBigQuery( connection *bigquery.Client, tableNames []Table, ) ([]TableColumnInfo, error)