繁体   English   中英

在服务器上安装 postgresql 数据库并在另一个 pc 客户端上运行 gui 应用程序

[英]install postgresql database on server and run gui application on another pc client

我使用 pyqt5 和 postgresql 数据库创建了 2 个 GUI 应用程序

其中之一是读写应用程序和 2 ND 只读应用程序

我想在一台包含只读应用程序的计算机上安装数据库,并在另一台计算机上安装该应用程序读写

请注意,2 台 PC 是使用 DHCP(动态主机配置协议)服务器连接的,我用来将应用程序连接到数据库的代码是这样的

connection = psycopg2.connect(user="postgres",
                               password="password",
                               host="localhost", 
                               port="5432",
                               database="SIFAX")

我如何配置 postgres 数据库和我的代码,使其成为可能

找到解决办法

文件中的第一个

pg_hba.conf

在 C:\\Program Files\\PostgreSQL\\12\\data 中添加客户端 pc 的 ip 地址,如下所示

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             x.x.x.x/32              md5#ip of the first client 
host    all             all             x.x.x.x/32              md5#ip of the 2nd client 

并且在服务器中使用的gui代码中它会是这样的

connection = psycopg2.connect(user="postgres",
                               password="password",
                               host="localhost", 
                               port="5432",
                               database="database")

和客户端PC中使用的gui代码将是这样的

connection = psycopg2.connect(user="postgres",
                               password="password",
                               host="ip adress of the server", 
                               port="5432",
                               database="database")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM