views:

362

answers:

2

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')
+3  A: 

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.

Ignacio Vazquez-Abrams
I was afraid of that. I wanted to use a MySQL db, but I am limited to using the version of Python bundled with OS X 10.5 ( 2.5.1).. I cannot import modules like mySQLdb not included in 2.5.1... Is there another module that is part of the Standard Libray of 2.5.1 that can handle SQL commands that could talk to something like PostgreSQL?
CaseyIT
There are no client/server DBMS modules in the Python standard library.
Ignacio Vazquez-Abrams
+1  A: 

The sqlite FAQ has an answer relevant to your question. It points out that although multi-machine network access is theoretically possible (using a remote filesystem) it likely won't be reliable unless the filesystem properly supports locks.

If you're accessing it from only one machine and process at a time, however, it should work acceptably, as that page notes (and dependent on the remote filesystem you're using).

Peter Hansen