c语言连接pg数据库,可以使用语句:
EXEC SQL CONNECT TO target [AS connection-name] [USER user-name];
target可以用下列方法指定:
dbname[@hostname][:port]
tcp:postgresql://hostname[:port][/dbname][?options]
unix:postgresql://hostname[:port][/dbname][?options]
一个包含上述形式之一的 SQL 字符串
到一个包含上述形式之一(参见例子)的字符变量的引用
DEFAULT
指定用户名(user-name)的方法:
[username IDENTIFIED BY password]
具体举例:
exec sql connect to :targer user :user indetified by :passwd;