使用Python连接到远程sqlite3数据库 [英] Connect to a remote sqlite3 database with Python

查看:1288
本文介绍了使用Python连接到远程sqlite3数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下方法创建到本地sqlite3数据库的连接(使用Mac OS X 10.5和Python 2.5.1):

I am able to create a connection to a local sqlite3 database ( Using Mac OS X 10.5 and Python 2.5.1 ) with this:

conn = sqlite3.connect('/db/MyDb')

如果该数据库位于服务器上(例如,运行IP地址为10.7.1.71的运行Ubuntu 8.04的服务器上)并且未存储在本地,该如何连接到该数据库?

How can I connect to this database if it is located on a server ( for example on a server running Ubuntu 8.04 with an IP address of 10.7.1.71 ) , and is not stored locally?

例如这似乎不起作用:

conn = sqlite3.connect('10.7.1.71./db/MyDb')

推荐答案

SQLite仅是嵌入式的.您需要先挂载远程文件系统,然后才能访问它.而且,不要尝试一次让多台机器访问SQLite数据库. SQLite不是为此而构建的.如果需要,请改用类似PostgreSQL的东西.

SQLite is embedded-only. You'll need to mount the remote filesystem before you can access it. And don't try to have more than one machine accessing the SQLite database at a time; SQLite is not built for that. Use something like PostgreSQL instead if you need that.

这篇关于使用Python连接到远程sqlite3数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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