类: PGClient
postgres.PGClient PGClient 是一个用于 Postgres 数据库的客户端。 内部客户端使用 go-pg/pg 驱动程序。示例
目录
构造函数
方法
构造函数
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
示例
定义于
postgres.ts:44ConnectWithDB
▸ ConnectWithDB(host, port, username): boolean
ConnectWithDB 使用给定的凭据和数据库名称连接到 Postgres 数据库。
如果连接成功,它返回 true。
如果连接不成功,它返回 false 和错误。
函数返回后连接关闭。
参数
| 名称 | 类型 |
|---|---|
host | string |
port | number |
username | string |
返回
boolean
示例
定义于
postgres.ts:78ExecuteQuery
▸ ExecuteQuery(host, port, username): SQLResult
ExecuteQuery 使用给定的凭据和数据库名称连接到 Postgres 数据库,
并在数据库上执行查询。
如果连接成功,它返回查询的结果。
参数
| 名称 | 类型 |
|---|---|
host | string |
port | number |
username | string |
返回
SQLResult
示例
定义于
postgres.ts:61IsPostgres
▸ IsPostgres(host, port): boolean
IsPostgres 检查给定的主机和端口是否运行 Postgres 数据库。
如果连接成功,它返回 true。
如果连接不成功,它返回 false 和错误。
参数
| 名称 | 类型 |
|---|---|
host | string |
port | number |
返回
boolean
示例