Documentation Index
Fetch the complete documentation index at: https://projectdiscovery.sec-lab.cn/llms.txt
Use this file to discover all available pages before exploring further.
类: PGClient
postgres.PGClient
PGClient 是一个用于 Postgres 数据库的客户端。
内部客户端使用 go-pg/pg 驱动程序。
示例
const postgres = require('nuclei/postgres');
const client = new postgres.PGClient;
构造函数
构造函数
constructor
• new PGClient(): PGClient
PGClient
定义于
postgres.ts:16
Connect
▸ Connect(host, port, username): boolean
Connect 使用给定的凭据连接到 Postgres 数据库。
如果连接成功,它返回 true。
如果连接不成功,它返回 false 和错误。
函数返回后连接关闭。
| 名称 | 类型 |
|---|
host | string |
port | number |
username | string |
boolean
示例
const postgres = require('nuclei/postgres');
const client = new postgres.PGClient;
const connected = client.Connect('acme.com', 5432, 'username', 'password');
定义于
postgres.ts:44
ConnectWithDB
▸ ConnectWithDB(host, port, username): boolean
ConnectWithDB 使用给定的凭据和数据库名称连接到 Postgres 数据库。
如果连接成功,它返回 true。
如果连接不成功,它返回 false 和错误。
函数返回后连接关闭。
| 名称 | 类型 |
|---|
host | string |
port | number |
username | string |
boolean
示例
const postgres = require('nuclei/postgres');
const client = new postgres.PGClient;
const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname');
定义于
postgres.ts:78
ExecuteQuery
▸ ExecuteQuery(host, port, username): SQLResult
ExecuteQuery 使用给定的凭据和数据库名称连接到 Postgres 数据库,
并在数据库上执行查询。
如果连接成功,它返回查询的结果。
| 名称 | 类型 |
|---|
host | string |
port | number |
username | string |
SQLResult
示例
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));
定义于
postgres.ts:61
IsPostgres
▸ IsPostgres(host, port): boolean
IsPostgres 检查给定的主机和端口是否运行 Postgres 数据库。
如果连接成功,它返回 true。
如果连接不成功,它返回 false 和错误。
boolean
示例
const postgres = require('nuclei/postgres');
const isPostgres = postgres.IsPostgres('acme.com', 5432);
定义于
postgres.ts:27