postgres

package
v3.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT, Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Warning - This is generated code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PGClient

type PGClient struct{}

PGClient is a client for Postgres database. Internally client uses go-pg/pg driver. @example ```javascript const postgres = require('nuclei/postgres'); const client = new postgres.PGClient; ```

func (*PGClient) Connect

func (c *PGClient) Connect(host string, port int, username, password string) (bool, error)

Connect connects to Postgres database using given credentials. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns. @example ```javascript const postgres = require('nuclei/postgres'); const client = new postgres.PGClient; const connected = client.Connect('acme.com', 5432, 'username', 'password'); ```

func (*PGClient) ConnectWithDB

func (c *PGClient) ConnectWithDB(host string, port int, username, password, dbName string) (bool, error)

ConnectWithDB connects to Postgres database using given credentials and database name. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns. @example ```javascript const postgres = require('nuclei/postgres'); const client = new postgres.PGClient; const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname'); ```

func (*PGClient) ExecuteQuery

func (c *PGClient) ExecuteQuery(host string, port int, username, password, dbName, query string) (*utils.SQLResult, error)

ExecuteQuery connects to Postgres database using given credentials and database name. and executes a query on the db. If connection is successful, it returns the result of the query. @example ```javascript const postgres = require('nuclei/postgres'); const client = new postgres.PGClient; const result = client.ExecuteQuery('acme.com', 5432, 'username', 'password', 'dbname', 'select * from users'); log(to_json(result)); ```

func (*PGClient) IsPostgres

func (c *PGClient) IsPostgres(host string, port int) (bool, error)

IsPostgres checks if the given host and port are running Postgres database. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. @example ```javascript const postgres = require('nuclei/postgres'); const isPostgres = postgres.IsPostgres('acme.com', 5432); ```

Jump to

Keyboard shortcuts

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