postgres

package module
v0.0.0-...-a9016dc Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

README

Postgres interface

Generic postgres interface for Go. This package creates a generic interface to interact with a PostgreSQL server. Provides basic query methods and table representations.

Usage

See postgres_test.go for examples

View API docs

More docs coming soon

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDB

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

PostgresDB represents a PostgreSQL database connection.

func NewPostgresDB

func NewPostgresDB(connectionString string) (*PostgresDB, error)

NewPostgresDB creates a new instance of PostgresDB with the provided connection string.

func (*PostgresDB) Close

func (p *PostgresDB) Close() error

Close closes the database connection.

func (*PostgresDB) CreateTable

func (p *PostgresDB) CreateTable(table Table) error

CreateTable creates a table in the database based on the provided Table.

func (*PostgresDB) DeleteRows

func (p *PostgresDB) DeleteRows(tableName, condition string, args ...interface{}) (sql.Result, error)

DeleteRows deletes rows from the table based on the provided condition.

func (*PostgresDB) DropTable

func (p *PostgresDB) DropTable(tableName string) error

DropTable drops a table from the database.

func (*PostgresDB) InsertRow

func (p *PostgresDB) InsertRow(tableName string, values ...interface{}) error

InsertRow inserts a new row into the table.

func (*PostgresDB) SelectRows

func (p *PostgresDB) SelectRows(tableName, condition string, args ...interface{}) (*sql.Rows, error)

SelectRows selects rows from the table based on the provided condition.

type Table

type Table struct {
	Name    string
	Columns []TableColumn
}

Table represents a database table.

type TableColumn

type TableColumn struct {
	Name string
	Type string
}

TableColumn represents a column in a database table.

Jump to

Keyboard shortcuts

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