By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

Python and MySQL

P: n/a
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

Nov 2 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
[Aquarius]
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


Possibly not want you want to hear, but I'd strongly recommend to stop
wasting your time with a hosting company that doesn't support the
technologies you need.

Instead, try a hosting company that supports python: there are lots and lots

http://wiki.python.org/moin/PythonHosting

Life's too short to spend your time hacking around artificial barriers
to progress.

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Nov 2 '05 #2

P: n/a
Aquarius wrote:
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

You'll definitely need something to call the database API functions, I
suspect.

You could do a *private* install of the module though, surely, on your
web host?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 2 '05 #3

P: n/a
Aquarius wrote:
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


I assume that MySQL clients talk to servers via sockets, and it should
be possible to write a python client that did that. It's probably some
work though, and it will probably piss MySQL AB off, since it means that
you could write MySQL client apps using whatever license you want
without paying them.

I wrote a prototype for such a client lib for PostgreSQL once, and it
was fairly simple, but the PostgreSQL docs have decent descriptions of
their protocol, while I assume MySQL hasn't since they want people to
use their client libs and pay for that. (If you read the client lib
source and translate that to Python, it should be considered a derivate,
and GPL applies. If you manage to get it to work without reading any
GPLed code, I guess you are entitled to use whatever license you want.)
Disclaimer: IANAL.
Nov 2 '05 #4

P: n/a
"Aquarius" <st**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private
directory. There is nothing secret here.

But

As others have already pointed out, after you go to this trouble, your
hosting provider will still suck! I'm sure you can you can get lot's of
suggestions for a suitable replacement.

Thomas Bartkus
Nov 2 '05 #5

P: n/a
Thomas Bartkus wrote:
"Aquarius" <st**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private
directory. There is nothing secret here.

But

As others have already pointed out, after you go to this trouble, your
hosting provider will still suck! I'm sure you can you can get lot's of
suggestions for a suitable replacement.

I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 2 '05 #6

P: n/a
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private directory. There is nothing secret here.

I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?


You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:
print MySQLdb.version_info

(1, 2, 0, 'final', 1)

There doesn't seem to be .c code to be found anywhere.
Thomas Bartkus
Nov 2 '05 #7

P: n/a
Thomas Bartkus wrote:
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no
reason
why you couldn't just take these modules and put them in your own
private
directory. There is nothing secret here.


I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:

print MySQLdb.version_info


(1, 2, 0, 'final', 1)

OK. I saw that my own version was (1, 0, 0, 'final', 1), so I assumed
Andy's updated the package somewhat. However, downloading the source of
1.2 I see that _mysql.c still appears, and that the package's
__init__.py still includes the line

include _mysql

My C:\Python24\Lib\site-packages directory does contain a _mylsql.pyd
file. Would you like to check that we are talking about the same module?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 3 '05 #8

P: n/a
I am also have _mysql.c that has to be compiled. I downloaded 1.2.0
from here
http://sourceforge.net/project/showf...ckage_id=15775
(the .tar.gz). Do you mean, that if I drop the import _mysql and from
_mysql import ... lines everything will work OK? I "private install"
would be great for me, if it works :D

Nov 3 '05 #9

P: n/a
Aquarius <st**********@gmail.com> wrote:
I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


If you've got MySQL installed, you probably have a command-line
mysql client, and you could use subprocess or popen to run that.
That's a little desperate though, and the error handling will suck.
(I've seen this trick used with other databases.)

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Nov 3 '05 #10

P: n/a
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:

>print MySQLdb.version_info


(1, 2, 0, 'final', 1)

OK. I saw that my own version was (1, 0, 0, 'final', 1), so I assumed
Andy's updated the package somewhat. However, downloading the source of
1.2 I see that _mysql.c still appears, and that the package's
__init__.py still includes the line

include _mysql

My C:\Python24\Lib\site-packages directory does contain a _mylsql.pyd
file. Would you like to check that we are talking about the same module?


Okay - I neglected to look at the [site-packages] directory itself. Here I
do find [_mysql.pyd] full of binary code. A MySQLdb related file that
doesn't seem to have a corresponding file with Python source code. Mea
culpa! This is on MS Windows [C:\Python23].

But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].

print MySQLdb.version_info
(0, 9, 2, 'final', 1)

Thomas Bartkus

Nov 3 '05 #11

P: n/a
Thomas Bartkus wrote:
[some posters having the idea that MySQLdb works without a C extension]
Okay - I neglected to look at the [site-packages] directory itself. Here I
do find [_mysql.pyd] full of binary code. A MySQLdb related file that
doesn't seem to have a corresponding file with Python source code. Mea
culpa! This is on MS Windows [C:\Python23].

But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].


MySQLdb is based on a C extension module called _mysql on all platforms.
The C extension modules have the extension ".pyd" on Windows by default,
and ".so" on Unix.

It would in theory be possible to do without a C extension, but then you
would have to implement the MySQL client-server protocol
(http://dev.mysql.com/doc/internals/e...-protocol.html) in
Python, for example using the socket module.

Implementing a pure-Python package to interface a database by
implementing the client-server protocol in Python has been done already
for PostgreSQL, but I don't think it has been done for MySQL, yet.

-- Gerhard

Nov 3 '05 #12

P: n/a
Thomas Bartkus wrote:
But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].


I suspect you might find _mysql.so there. If you find any .pyd files I
think you can safely remove them, since Windows DLLs work poorly in
Linux anyway. Aren't you starting to suspect that you don't really know
what you are talking about in this particular case? Where is the pure
Python code that actually communicates with the database server? Have
you found a single line of code that actually does that? How does it
communicate? Isn't there an 'import _mysql' somewhere? Where is the
_mysql.py then?

What's this?
http://cvs.sourceforge.net/viewcvs.p...SQLdb/_mysql.c

What's this doing in setup.py?
'ext_modules': [
Extension(
name='_mysql',
sources=['_mysql.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
),
],
Nov 3 '05 #13

P: n/a
"Magnus Lycka" <ly***@carmen.se> wrote in message
news:dk**********@wake.carmen.se...
Thomas Bartkus wrote:
But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while there are other file extensions, everything seems to have a corresponding [.py].
I suspect you might find _mysql.so there. If you find any .pyd files I
think you can safely remove them, since Windows DLLs work poorly in
Linux anyway. Aren't you starting to suspect that you don't really know
what you are talking about in this particular case?


Yes!

And thank you so much for pointing that out :-)
Thomas Bartkus
Where is the pure
Python code that actually communicates with the database server? Have
you found a single line of code that actually does that? How does it
communicate? Isn't there an 'import _mysql' somewhere? Where is the
_mysql.py then?

What's this?
http://cvs.sourceforge.net/viewcvs.p...SQLdb/_mysql.c

What's this doing in setup.py?
'ext_modules': [
Extension(
name='_mysql',
sources=['_mysql.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
),
],

Nov 3 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.