暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

连接PostgreSQL时,如何指定参数

digoal 2017-03-07
703

作者

digoal

日期

2017-03-07

标签

PostgreSQL , conninfo


背景

连接数据库时,如何配置默认参数?

libpq

https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-CONNSTRING

所有支持的连接参数都在以上链接中

KV模式

配置连接串时,可以使用KV模式,例子

host=localhost port=5432 dbname=mydb connect_timeout=10

URI模式

也可以使用URI模式,例子

postgresql:// postgresql://localhost postgresql://localhost:5433 postgresql://localhost/mydb postgresql://user@localhost postgresql://user:secret@localhost postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp

options

对于其他参数,需要通过options指定,例子如下

psql "host=localhost port=1921 dbname=postgres connect_timeout=10 sslmode=disable options='-c work_mem=64 -c lock_timeout=1'"

参考

https://www.postgresql.org/docs/9.6/static/libpq-connect.html#LIBPQ-CONNSTRING

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论