SQLite通过网络 [英] SQLite over a network

查看:209
本文介绍了SQLite通过网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个使用嵌入式SQLite数据库的Python应用程序。该程序创建数据库文件,它们位于共享网络驱动器上。此时网络上将运行程序的计算机不超过5台。



我最初的想法是询问用户在启动时是否是服务器或客户端。如果他们是服务器,那么他们创建数据库。如果他们是客户端,他们必须在网络上找到一个服务器实例。我假设的一种方法是将所有db命令从客户端发送到数据库中的服务器和服务器实现。这将解决共享的数据库问题?



或者,是否有一些方法来创建SQLite服务器。

我不能使用MySQL或PostgreSQL等服务器引擎

解决方案

这里是一个 SQLite Server, http://sqliteserver.xhost.ro/ ,但它看起来像在维护多年。



SQLite支持并发性,多个进程可以一次读取数据,只有一个可以写入数据。此外,当一些进程正在写时,它将锁定整个数据库文件几秒钟,而其他进程正在等待官方文档。



我猜这对于5个进程来说足够了。只需要写代码来处理等待。


I am creating a Python application that uses embedded SQLite databases. The programme creates the db files and they are on a shared network drive. At this point there will be no more than 5 computers on the network running the programme.

My initial thought was to ask the user on startup if they are the server or client. If they are the server then they create the database. If they are the client they must find a server instance on the network. The one way I suppose is to send all db commands from client to server and server implements in the database. Will that solve the shared db issue?

Alternatively, is there some way to create a SQLite "server". I presume this would be the quicker option if available?

Note: I can't use a server engine such as MySQL or PostgreSQL at this point but I am implementing using ORM and so when this becomes viable, it should be easy to change over.

解决方案

Here's a "SQLite Server", http://sqliteserver.xhost.ro/, but it looks like not in maintain for years.

SQLite supports concurrency itself, multiple processes can read data at one time and only one can write data into it. Also, When some process is writing, it'll lock the whole database file for a few seconds and others have to wait in the mean time according official document.

I guess this is sufficient for 5 processes as yor scenario. Just you need to write codes to handle the waiting.

这篇关于SQLite通过网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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