Truly platform-independent DB access in Python?

B

bobrik

Hello,

I am using the Python DB API for access to MySQL. But it is not
platform-independent - I need a module not included in Python by
default - python-mysql, and it uses a compiled binary _mysql.so. So it
is not platform-independent because for each web-server on different
platform, I would have to download it and extra compile it specifically
for that platform. Do you know of any Python solution for MySQL access
that is 100% platform-independent?

Thanks for any suggestions.
Boris Dušek
 
L

lbolognini

bobrik said:
I am using the Python DB API for access to MySQL. But it is not
platform-independent - I need a module not included in Python by
default - python-mysql, and it uses a compiled binary _mysql.so. So it
is not platform-independent because for each web-server on different
platform, I would have to download it and extra compile it specifically
for that platform. Do you know of any Python solution for MySQL access
that is 100% platform-independent?

Probably SqlAlchemy
http://www.sqlalchemy.org/

Lorenzo
 
B

Bruno Desthuilliers

bobrik said:
Hello,

I am using the Python DB API for access to MySQL. But it is not
platform-independent

It is. You don't have to change your Python code according to the OS or
CPU.
 
S

skip

boris> I am using the Python DB API for access to MySQL. But it is not
boris> platform-independent - I need a module not included in Python by
boris> default - python-mysql, and it uses a compiled binary
boris> _mysql.so. So it is not platform-independent because for each
boris> web-server on different platform, I would have to download it and
boris> extra compile it specifically for that platform. Do you know of
boris> any Python solution for MySQL access that is 100%
boris> platform-independent?

I don't think you mean "platform-independent". I suspect you mean
"batteries included". Prior to the release of Python 2.5, no modules to
access SQL databases were distributed with core Python. Starting with 2.5,
sqlite access will be available:
'/Users/skip/local/lib/python2.5/sqlite3/__init__.pyc'

So, if what you were really asking was "what SQL databases can I access
without installing any software other than Python?", then the answer is "No
SQL databases were distributed with Python prior to 2.5. Starting with
Python 2.5, access to sqlite databases is available by default." Python 2.5
is due out soon (according to PEP 356, on 12 September).

The still-officially-in-development-but-almost-certainly-frozen
documentation for the sqlite3 module is here:

http://docs.python.org/dev/lib/module-sqlite3.html

Skip
 
?

=?iso-8859-1?B?Qm9yaXMgRHWaZWs=?=

Bruno said:
It is. You don't have to change your Python code according to the OS or
CPU.
What I mean is that wiht platform-independent access, I should be able
to not care on which operating system is the web server accessing my
scripts where I use MySQLdb which I have to install (and therfore
platform-dependently) compile myself. The important point is that
MySQLdb is installed as an extra module. So you have to compile it
manually, but what if the OS with server accessing the site that is on
shared area changes?
 
?

=?iso-8859-1?B?Qm9yaXMgRHWaZWs=?=

I don't think you mean "platform-independent". I suspect you mean
"batteries included". Prior to the release of Python 2.5, no modules to
access SQL databases were distributed with core Python. Starting with 2.5,
sqlite access will be available:

'/Users/skip/local/lib/python2.5/sqlite3/__init__.pyc'

So, if what you were really asking was "what SQL databases can I access
without installing any software other than Python?", then the answer is "No
SQL databases were distributed with Python prior to 2.5. Starting with
Python 2.5, access to sqlite databases is available by default." Python 2.5
is due out soon (according to PEP 356, on 12 September).

Yes, you excactly got my point. The thing is that I can't rely on
Python 2.5 to be installed soon.
So the only solution for me at this moment is to use jython and from
there use Java JDBC API (sorry :) But it would be great if the Python
DB API compliant-modules would become parts of core python quickly.
Python DB API itself is a great thing.
 
D

Diez B. Roggisch

Yes, you excactly got my point. The thing is that I can't rely on
Python 2.5 to be installed soon.
So the only solution for me at this moment is to use jython and from
there use Java JDBC API (sorry :) But it would be great if the Python
DB API compliant-modules would become parts of core python quickly.
Python DB API itself is a great thing.

They won't be. The reason that sqlite is is because it is self-contained.
But your average DB itself you need to install using a platform-specific
build. And building the the extensions even requires proprietary libraries
installed (think of oracle) - so without having installed a dozen or more
DBs, no one could build python!

So - no chance that this will ever happen. The only thing you could do is to
try and convince the DB-vendors to provide pure python DB drivers - as they
do it for java.

Diez
 
B

Bruno Desthuilliers

Boris said:
What I mean is that wiht platform-independent access, I should be able
to not care on which operating system is the web server accessing my
scripts where I use MySQLdb

When it comes to *using* MySQLdb, you don't care about the OS, CPU and
whatnot.
which I have to install (and therfore
platform-dependently) compile myself.

This is a very distinct problem.
The important point is that
MySQLdb is installed as an extra module. So you have to compile it
manually,

Usually said:
but what if the OS with server accessing the site that is on
shared area changes?

And what if Python is not installed on it ?-)

Seriously, do you think that hosting companies swap OS very often ?
 
?

=?iso-8859-1?B?Qm9yaXMgRHWaZWs=?=

Bruno said:
And what if Python is not installed on it ?-)

Seriously, do you think that hosting companies swap OS very often ?

No, I don't. But I was trying to find the best solution. :)
 
S

Steve Holden

Bruno said:
When it comes to *using* MySQLdb, you don't care about the OS, CPU and
whatnot.




This is a very distinct problem.




And what if Python is not installed on it ?-)

Seriously, do you think that hosting companies swap OS very often ?
Well, GoDaddy just switched enough domains from Linux to Windows to make
a significant difference to the Internet hosting statistics, and were
allegedly paid handsomely by Microsoft to do it, but those were parked
domains.

regards
Steve
 
?

=?iso-8859-1?B?Qm9yaXMgRHWaZWs=?=

Dennis said:
Subprocess module invoking the MySQL command line utilities? Of
course, parsing the results will be painful...
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/

Hmm, that is very interesting; and parsing won't be IMHO such a problem
if the columns will be tab-separated. Thanks for your tip!
 
B

Ben Finney

Boris Duek said:
Yes, you excactly got my point. The thing is that I can't rely on
Python 2.5 to be installed soon.
So the only solution for me at this moment is to use jython and from
there use Java JDBC API (sorry :)

Assuming Java is installed on an arbitrary machine seems to be exactly
the sort of assumption you said you *don't* want to make.

How about this: Please lay out the assumptions you *are* willing to
make about the target platform, and what you want to do on that
platform.
 
D

Dennis Lee Bieber

Hmm, that is very interesting; and parsing won't be IMHO such a problem
if the columns will be tab-separated. Thanks for your tip!

Frith preserve me... I'd "said" that in a cynical manner <G>

I might have to check the MySQL reference regarding a tab separated
output mode -- normal output is ASCII "blocked"... ( | data | data |
etc.)

(Hmmm, I see I also need to change the system wide PATH... need one more
"MySQL" level in it)

--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
?

=?iso-8859-1?B?Qm9yaXMgRHWaZWs=?=

So, if what you were really asking was "what SQL databases can I access
without installing any software other than Python?", then the answer is "No
SQL databases were distributed with Python prior to 2.5. Starting with
Python 2.5, access to sqlite databases is available by default." Python 2.5
is due out soon (according to PEP 356, on 12 September).

So I finally decided to go with sqlite, compile the module myself for
the time being and hoping python will be upgraded to 2.5 at latest at
the same time as any potential OS (or architecture) upgrade.
 
J

Jorge Vargas

Hello,

I am using the Python DB API for access to MySQL. But it is not
platform-independent - I need a module not included in Python by
default - python-mysql, and it uses a compiled binary _mysql.so. So it
is not platform-independent because for each web-server on different
platform, I would have to download it and extra compile it specifically
for that platform. Do you know of any Python solution for MySQL access
that is 100% platform-independent?
I'm sorry but since when is MySQL platform independent? if
mysql-python will be pure python then it will probably be slower
because it will have to use sockets, or other type of IPC instead Andy
used mysql C API which is fast.

on the other hand all big *NIX distros have mysql-python on their
packages/tree, and I made a windows installer of the last version,
which you can get from sourceforge.

so the only problem I see here is if your on a mac, on which the
source should compile without problems since it's *NIX now.

at this moment installing on any mayor platform is 2-3 commands/clicks away..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top