简体   繁体   English

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

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

I have created 2 GUI applications using pyqt5 and postgresql database我使用 pyqt5 和 postgresql 数据库创建了 2 个 GUI 应用程序

one of them a read a write application and the 2 ND read only其中之一是读写应用程序和 2 ND 只读应用程序

I want to install the database on one computer that contain the application read only and in another computer the application read a write我想在一台包含只读应用程序的计算机上安装数据库,并在另一台计算机上安装该应用程序读写

Note that the 2 PC are connected using DHCP (Dynamic Host Configuration Protocol) server the code I use to connect my application to the database is like this请注意,2 台 PC 是使用 DHCP(动态主机配置协议)服务器连接的,我用来将应用程序连接到数据库的代码是这样的

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

How I can configure the postgres database and my code, making it possible我如何配置 postgres 数据库和我的代码,使其成为可能

find a solution找到解决办法

first in the file文件中的第一个

pg_hba.conf

in C:\\Program Files\\PostgreSQL\\12\\data add the ip adress of the client pc like this在 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 

and in the code of gui used in the server it will be like this并且在服务器中使用的gui代码中它会是这样的

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

and the code of the gui used in the client pc it will be like this和客户端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.

相关问题 python服务器和java客户端(另一台PC)错误 - python server and java client(another PC) Error 使用 Django 在另一台服务器上创建 PostgreSQL 数据库 - Create PostgreSQL Database on another Server using Django 一台PC上的ZeroMQ服务器和客户端 - ZeroMQ server and client on one PC 您需要安装 postgresql-server-dev-XY 以构建服务器端扩展或安装 libpq-dev 以构建客户端应用程序 - You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application 我已经创建了1台服务器,该服务器可以将一台客户端连接到另一台PC上,并将另一台客户端连接为Localhost? - I have created 1 server which connect one client in another PC and another one as Localhost? 在另一台PC中复制Django项目(postgreSQL) - Copy a django project in another PC (postgreSQL) 为 python 客户端服务器创建 Gui - Creating Gui for python client server 与Flask应用程序同时运行GUI - Run GUI concurrently with Flask application 强制GUI应用程序以root身份运行 - Forcing a GUI application to run as root 无法使用docker运行客户端 - 服务器应用程序 - Can't run client-server application with docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM