天天看點

python資料庫sqlite3,使用Python連接配接到遠端sqlite3資料庫

python資料庫sqlite3,使用Python連接配接到遠端sqlite3資料庫

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

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?

e.g. this does not seem to work:

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

解決方案

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.