JII*_*JII 189 postgresql database-connection
当主机是除localhost之外的其他计算机时,PostgreSQL连接URL是如何形成的?
我允许PostgreSQL接受来自外部的请求.
And*_*rey 329
如果对各自的语言使用Libpq绑定,则根据其文档 URI形成如下:
postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
Run Code Online (Sandbox Code Playgroud)
以下是同一文档中的示例
postgresql://
postgresql://localhost
postgresql://localhost:5432
postgresql://localhost/mydb
postgresql://user@localhost
postgresql://user:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://localhost/mydb?user=other&password=secret
Run Code Online (Sandbox Code Playgroud)
Hem*_*ari 42
以下对我有用
const conString = "postgres://YourUserName:YourPassword@YourHost:5432/YourDatabase";
Run Code Online (Sandbox Code Playgroud)
nos*_*nos 15
这是JDBC的文档,一般URL是"jdbc:postgresql:// host:port/database"
第3章这里记录了ADO.NET连接字符串,一般连接字符串是Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;
这里的 PHP文档,一般的连接字符串是
host=hostname port=5432 dbname=databasename user=username password=secret
如果你正在使用别的东西,你必须告诉我们.
DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
Run Code Online (Sandbox Code Playgroud)
DATABASE_URL=postgresql://username:password@host:port/dtabase_name
Run Code Online (Sandbox Code Playgroud)
DATABASE_URL=postgresql+asyncpg://username:password@host:port/dtabase_name
Run Code Online (Sandbox Code Playgroud)
- 请记住永远不要推送您的数据库密码,因此您应该使用您的
DATABASE_URL
文件.env
port
如果您使用默认值,则该选项是可选的
像这样,您可以连接本地和远程数据库,想象一下,一旦您想要检查远程部署版本中发生的问题
localhost DATABASE_URL 的 ex 是
DATABASE_URL=postgresql+asyncpg://postgres:dina@localhost/mysens
Run Code Online (Sandbox Code Playgroud)
uri
到您的数据库DATABASE_URL=postgresql+asyncpg://sqnalxxxxxxxxx:160xxxx2bdd2942b26c93c392xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@ec2-35-173-91-114.compute-1.amazonaws.com:5432/del6o4cjoqfsov
Run Code Online (Sandbox Code Playgroud)
小智 6
postgres 语法的连接 URL:
"Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;
Run Code Online (Sandbox Code Playgroud)
例子:
"Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;
Run Code Online (Sandbox Code Playgroud)
还可以通过编程方式从工作的数据库连接器中检索连接字符串。
例如,我有时从 SQLAlchemy 中提取连接字符串engine
,如下所示:
> db_engine.url
postgres://{user}:{password}@{host}:{port}/{db_name}?sslmode=require
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
189003 次 |
最近记录: |