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

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

问题描述

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

该程序将由少于5个人同时使用.因此,我正在考虑使用Sqlite3数据库,因为我认为它应该能够应付这么多的流量.

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

基本上,服务器将不过是远程数据存储.

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

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

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

(2)我的程序可以/应该通过哪种方式通过Internet与该服务器通信.

即使您不能给我确切的答案,也希望您能提供一些有关我的信息,以便我查找和研究.

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

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

解决方案

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

您可以使用

  1. XMLRPC 以使用称为在服务器端

  2. 您可以对带有库 REST href ="https://stackoverflow.com/questions/2018026/should-i-use-urllib-or-urllib2-or-requests">客户端的请求或urllib

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

  4. 您可以使用 Pyro 来远程访问服务器上的对象.如果客户也应该彼此沟通,则很有用.

  5. 您可以创建自己的协议.您将学到很多东西,并珍视其他选项.

  6. 列表不完整

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

安全性很重要.我不是专家.如果您以纯文本格式发送用户名和密码,请使用SSL加密连接.如果无法让ssl与python一起使用,则可以使用隧道.

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.

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.

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.

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

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) 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)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.

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

解决方案

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

You can use

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

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

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

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

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

  6. The list is not complete

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.

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实现简单的Web数据存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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