MySQLdb - possible without install?

Ken ken_chiba at hotmail.com
Thu Jul 12 18:34:46 EDT 2001


Thanks for your continued help...  I'm hitting a wall:  I've compiled
MySQLdb (on python 1.5.2) -- I believe that's what my ISP's using, and
I have the files I (think I) need:

_mysql.so
_mysql_exceptions.py(c)
MySQLdb
  - lots of files, and 'constants' within.

I've copied these three files, plus the MySQLdb directory to the
cgi-bin directory on the host.  I placed a simple python script in the
cgi-bin directory that just has:

#!/usr/contrib/bin/python  (the python path)
import MySQLdb
print "Content-Type: text/html\n\n" (so the browser doesn't choke).

I get a server 500 message, and checking the error_log file, I get:

Traceback (innermost last):
  File "test.cgi", line 4, in ?
    import MySQLdb
  File "MySQLdb/__init__.py", line 27, in ?
    import _mysql
ImportError: File not found
[Thu Jul 12 17:25:48 2001] [error] [client 206.47.244.60] Premature
end of script headers: /usr/home/v1/a0005722/html/cgi-bin/test.cgi

I've placed a copy of _mysql.so in both the root cgi-bin directory,
and into the MySQLdb directory (since __init__.py is located there).
But no luck!  I looked for a _mysql file (without the .so), but could
not find one.

What am I doing wrong??

Thanks!

Ken


On Thu, 12 Jul 2001 21:38:48 +0200, gerhard.nospam at bigfoot.de (Gerhard
=?iso-8859-1?Q?H=E4ring?=) wrote:

>On Thu, 12 Jul 2001 10:26:22 GMT, Ken <ken_chiba at hotmail.com> wrote:
>>I'm no expert with this at all... could I get some pointers?  I'm
>>assuming that you're saying that I need to compile MySQLdb with the
>>MySQL and Python versions that my provider uses.  This will result in
>>the creation of a MySQLdb directory in the site-packages directory of
>>Python.  Does it produce anything else?
>
>To build MySQLdb, you might have to change some paths in setup.py, then do a
>"python setup.py build". The files to install will then be in a directory named
>not entirely unlike "build/lib.linux-i686-2.1". This directory is normally
>copied to your site-packages dir. A simple way to use it on your provider is to
>copy all of it into your cgi-bin (the py[c] files, the binary extension module
>and the MySQLdb directory in it).
>
>>After this is created, do I just copy that directory (MySQLdb) to a
>>MySQLdb directory on the provider side (in this case.. within
>>cgi-bin)?  And finally, what line can I put within my scripts to pull
>>this information in? (ie.:  import ??)
>
>Better look into the MySQLdb docs, but here's a simple one:
>
>#!/usr/bin/env python
>import MySQLdb
>con = MySQLdb.connect( user = "me", password = "verysecret", db = "mydb",\
>    host = "dbcluster" )
>cursor = con.cursor()
>cursor.execute( "select hello from world" )
>print cursor.fetchall()
>
>>How can this keep track of what directory MySQL and Python are in? (or
>>are there configuration files that I can change - AFTER the compile?)
>
>No need to change any files *after* you compiled it. The dynamic loader must
>find the libmysqlclient library, or you'll have a problem. If this should
>really happen, you can perhaps link the Python extension module statically.
>You'll notice that this is the case when "import _mysql" produces something
>like:
>
>ImportError: libmysqlclient.so.10: cannot load shared object file: No such file
>or directory
>
>Hopefully, the standard way of setting "#!/usr/bin/env python" works as first
>line of your scripts. If not, you'll have to put the full path to the
>interpreter there ("#!/usr/local/bin/python" or whatever ...).
>
>Gerhard
>-- 
>mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
>web:    http://highqualdev.com              public key at homepage
>public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
>reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))




More information about the Python-list mailing list