469,267 Members | 938 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

Truly platform-independent DB access in Python?

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

Aug 28 '06 #1
16 2169
bobrik wrote:
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

Aug 28 '06 #2
lb********@gmail.com wrote:
bobrik wrote:
>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/
Probably not - I fail to see how SqlAlchemy could talk to MySQL without
the MySQL/Python binding.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Aug 28 '06 #3
bobrik wrote:
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.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Aug 28 '06 #4

borisI am using the Python DB API for access to MySQL. But it is not
borisplatform-independent - I need a module not included in Python by
borisdefault - python-mysql, and it uses a compiled binary
boris_mysql.so. So it is not platform-independent because for each
borisweb-server on different platform, I would have to download it and
borisextra compile it specifically for that platform. Do you know of
borisany Python solution for MySQL access that is 100%
borisplatform-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:
>>import sqlite3
sqlite3.__file__
'/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
Aug 28 '06 #5

Bruno Desthuilliers wrote:
bobrik wrote:
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.
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?

Aug 28 '06 #6
sk**@pobox.com wrote:
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:
>>import sqlite3
>>sqlite3.__file__
'/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.

Aug 28 '06 #7
Boris Dušek wrote:
So the only solution for me at this moment is to use jython and from
there use Java JDBC API (sorry :-)
so who installed Java for you?

</F>

Aug 28 '06 #8
>
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
Aug 28 '06 #9
Boris Dušek wrote:
Bruno Desthuilliers wrote:
>bobrik wrote:
>>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.
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, cd <src-dir&& python setup.py install do the job.
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 ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Aug 28 '06 #10

Bruno Desthuilliers wrote:
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 ?
No, I don't. But I was trying to find the best solution. :-)

Aug 28 '06 #11
Bruno Desthuilliers wrote:
Boris Dušek wrote:
>>Bruno Desthuilliers wrote:
>>>bobrik wrote:

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.

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, cd <src-dir&& python setup.py install do the job.

>>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 ?
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
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Aug 28 '06 #12

Dennis Lee Bieber wrote:
On 28 Aug 2006 00:01:06 -0700, "bobrik" <bo*********@gmail.com>
declaimed the following in comp.lang.python:

for that platform. Do you know of any Python solution for MySQL access
that is 100% platform-independent?
Subprocess module invoking the MySQL command line utilities? Of
course, parsing the results will be painful...
--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.com)
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!

Aug 28 '06 #13
"Boris Duek" <bo*********@gmail.comwrites:
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.

--
\ "My classmates would copulate with anything that moved, but I |
`\ never saw any reason to limit myself." -- Emo Philips |
_o__) |
Ben Finney

Aug 29 '06 #14
Boris Dušek wrote:
Bruno Desthuilliers wrote:
>>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 ?

No, I don't. But I was trying to find the best solution. :-)
Is there any reason to find a solution for a non-yet-existing problem ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Aug 29 '06 #15
sk**@pobox.com wrote:
... snip ...
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.

Aug 31 '06 #16
On 28 Aug 2006 00:01:06 -0700, bobrik <bo*********@gmail.comwrote:
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..
Thanks for any suggestions.
Boris Dušek

--
http://mail.python.org/mailman/listinfo/python-list
Aug 31 '06 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Web Master | last post: by
41 posts views Thread by Mark R. Dawson | last post: by
14 posts views Thread by John Salerno | last post: by
23 posts views Thread by Alvin | last post: by
reply views Thread by marathoner | last post: by
28 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
4 posts views Thread by Mufasa | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.