Python实现简单的网络数据存储 [英] Python implementing simple web data storage

查看:64
本文介绍了Python实现简单的网络数据存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个 python PyQt 程序,允许用户输入有关个人资料的数据,并在以后查看它们以进行处理.

I am trying to develop a python PyQt program that allow user to enter data about personal particulars and review them at a later time for processing purpose.

该程序将被少于 5 人同时使用.所以,我正在考虑使用 Sqlite3 数据库,因为我相信它应该能够应付这么大的流量.

The program will be used by less than 5 persons at the same time. So, i am thinking to use Sqlite3 database as i believe it should be able to cope for that amount of traffic.

我想到的框架是,客户将在每台机器上拥有自己的 python pyqt 程序副本.每当他们执行任何需要读取/写入数据的操作时,它都会通过 Internet 连接到服务器,并从服务器上的 sqlite.db 读取/写入.

The frame work i have in mind is that, the clients will have their own copy of my python pyqt program on each machine. Whenever they perform any operations that required data read/write, it will connect to the server thorough internet and read/write from the sqlite.db on the server.

基本上,服务器只是一个远程数据存储.

Basically, the server will be nothing but a remote data storage.

目前,我能够通过使用各种小部件(如QlineEditQComboboxQTextEdit)来为数据输入创建所需的GUI 等.

Currently, i am able to create the required GUI for data inputs by using various widgets like QlineEdit, QCombobox, QTextEdit and so on.

但我以前从未做过网络编程,因此我不知道如何实现一个服务器来为我的软件存储 sqlite 数据文件.所以我的问题是

But i have never done network programming before, thus i have no idea how to implement a server that store the sqlite data file for my software. So my questions are

(1) 如果我有一台可以 24/7 全天候网络连接的 PC,我该如何设置它以便它可以充当服务器来存储我的软件的数据文件?

(1) if i have a PC that has 24/7 internet connection, how do i set it up so that it can act as a server that store the data file for my software?

(2)我的程序可以/应该以什么方式通过互联网与该服务器通信.

(2)In what way can/should my program communicate to that server through internet.

即使你不能给我确切的答案,我也很感激你能提供一些信息,以便我查阅和研究.

Even if you can't give me exact answer, i would appreciate if you can provide me some information of so that i look up and study about it.

任何建设性的建议将不胜感激.

Any constructive advice will be appreciated.

仅供参考:所有 PC 都将运行 32 位 Windows XP SP3.

FYI: all the PCs will be running windows XP SP3 32 bits.

推荐答案

客户端与服务器通信的方式有多种.

There are different ways for a client to communicate with a server.

你可以使用

  1. XMLRPC 使用被调用的方法创建对象在服务器端

  1. XMLRPC to create an object with methods that are called on the server side

您可以将 HTTP 和 REST 用于带有库的服务器 requests 或 urllib 为客户端

You can use HTTP and REST for the server with the library requests or urllib for the client

对于后者,您可以使用flask、bottle、django 或其他框架来创建一个提供内容的网站(教程)

For the latter you can use flask, bottle, django or other frameworks to create a website that serves the content (tutorials)

您可以使用 Pyro 远程访问服务器上的对象.如果客户端还应该相互通信,则很有用.

You can use Pyro to remotely access the objects on the server. Useful if the clients should also communicate with eachother.

您可以创建自己的协议.你会学到很多东西,并重视其他选择.

You can create your own protocol. You will learn a lot and value the other options.

列表不完整

如果合适,我建议您看看 XMLRPC.对于第 2 点,我可以说许多 API 都使用这样的 HTTP 接口(twitter、github、facebok、google).其他人也很容易使用.

I suggest that you have a look at XMLRPC if that fits. For number 2 I can say that many APIs use such a HTTP-interface (twitter, github, facebok, google). It is easy to use also for other people.

安全很重要.我不是专家.如果您以纯文本形式发送用户名和密码,则使用 SSL 加密连接.如果您无法使用 ssl 使用 python,您可以使用 stunnel.

Security is important. I am not an expert. If you send username and password in plain text then use SSL to encrypt the connection. If you can not get ssl to work with python you can use stunnel.

这篇关于Python实现简单的网络数据存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆