Documentation ¶
Overview ¶
Package connector contains structs and interfaces to connect to the database and get the descriptions. The main piece is the DBConnector interface that defines what specific connectors should implement. Currently a specific implementation is provided (postgres) but others could be added in the future.
Index ¶
- type DBConnector
- type Input
- type PostgresDBConnector
- func (dbConnector PostgresDBConnector) GetColumnsQueryStatement() string
- func (dbConnector PostgresDBConnector) GetConnection() (*sql.DB, error)
- func (dbConnector PostgresDBConnector) GetDatabaseTypeName() string
- func (dbConnector PostgresDBConnector) GetEntitiesQueryStatement() string
- func (dbConnector PostgresDBConnector) GetRelationsQueryStatement() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBConnector ¶
type DBConnector interface { // The database type of the connector. Example: postgres GetDatabaseTypeName() string // Gets a connection to the database after some credentials are provided GetConnection() (*sql.DB, error) /* A SQL query that brings the information for entities. Implementations are expected to provide the following columns: - table_schema (Schema of the entity) - table_name (Entity name) - table_type (Entity type: view/table) - comment (Entity comment) */ GetEntitiesQueryStatement() string /* A SQL query that brings the information for columns. Implementations are expected to provide the following columns: - table_schema (Schema of the entity) - table_name (Entity name) - column_name (The name of the column) - data_type (Data type of the column) - comment (Column comment) */ GetColumnsQueryStatement() string /* A SQL query that brings relations between entities (FKs). Implementations are expected to provide the following columns: - table_schema (Schema of the entity) - table_name (Entity name) - column_name (The name of the column) - constraint_name (The name of the fk) - foreign_table_schema (The name of the schema of the referenced table) - foreign_table_name (The name of the referenced table) - foreign_column_name (The name of the pk column in the referenced table) */ GetRelationsQueryStatement() string }
An interface defining methods needed to get the descriptions from a database.
DatabaseDescription contains a slice of `Schema`.
type Input ¶
type Input struct { Host string Port int User string Password string Name string Schemas []string Db string }
Input parameters.
A struct grouping the parameters for the main program, like the db credentials and the schemas names to process.
type PostgresDBConnector ¶
type PostgresDBConnector struct {
Input Input
}
A Postgres implementation of DBConnector.
Implement methods to connect to a postgres database and obtain information about its tables, views, and columns.
func (PostgresDBConnector) GetColumnsQueryStatement ¶
func (dbConnector PostgresDBConnector) GetColumnsQueryStatement() string
func (PostgresDBConnector) GetConnection ¶
func (dbConnector PostgresDBConnector) GetConnection() (*sql.DB, error)
func (PostgresDBConnector) GetDatabaseTypeName ¶
func (dbConnector PostgresDBConnector) GetDatabaseTypeName() string
func (PostgresDBConnector) GetEntitiesQueryStatement ¶
func (dbConnector PostgresDBConnector) GetEntitiesQueryStatement() string
func (PostgresDBConnector) GetRelationsQueryStatement ¶ added in v1.0.3
func (dbConnector PostgresDBConnector) GetRelationsQueryStatement() string