Documentation ¶
Overview ¶
Warning - This is generated code
Index ¶
- type PGClient
- func (c *PGClient) Connect(host string, port int, username, password string) (bool, error)
- func (c *PGClient) ConnectWithDB(host string, port int, username, password, dbName string) (bool, error)
- func (c *PGClient) ExecuteQuery(host string, port int, username, password, dbName, query string) (*utils.SQLResult, error)
- func (c *PGClient) IsPostgres(host string, port int) (bool, error)
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 ¶
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 ¶
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); ```