Python / MySQLdb

Status
Not open for further replies.

Korexio

New Member
Messages
5
Reaction score
0
Points
0
Hello!

I'm new to X10 Hosting, and found in the forums that python is supported. thats really great!

I ad a lots of problems running my first scripts ...
... file permission not set to 0755,
... Apache python handler not set
... newlines encoded with 0x0D instead of 0x0A,
... first output was not "Content-type: text/plain\n\n",
... path to python was wrong,

And so here are new problems i encountered:
Where is python? it seems to work with
"#!/usr/local/bin/python"
and
"#!/usr/bin/python"

Additionally i cant import MySQLdb.
I used the following script:

#!/usr/local/bin/python

print "Content-type: text/plain\n\n"
(replace "...." with spaces)
PHP:
try:
....import MySQLdb
....import string
except Exception, e:
....print e

it produced the output:
No module named MySQLdb

thats not good i think ;-)

so how can i use SQL/DB in my python scripts?
 

Dannz

New Member
Messages
43
Reaction score
0
Points
0
Hi Korexio. You've obviously dealt with most of the setup like Apache file handlers etc.

I'm also finding there is now a problem importing the MySQLdb module. It may or may not be related, but I am now also getting the following at the top of the display when I go to edit the scripts:

>>You are not using a utf-8 language file. You should not save utf-8 data or you will get corrupted results. Click here to change your language file.<<

Then when I click and change the language file to English it doesn't seem to save anything and next time I open the script I get the same message.

Still from the exception it looks like MySQLdb has somehow become lost and inaccessible, perhaps at the same time that the language config perhaps went AWOL.

Corey/Admin - could this module be reinstalled please. Could you also advise what to do about this language file config issue.
 

Korexio

New Member
Messages
5
Reaction score
0
Points
0
ALternative for MySQLdb

So is there another way to access the MySQL DB? Or is it just not possible at the moment (from the python point of view ;-))?
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
205
Points
63
Is it a python module? I'm really not familiar with Python. If you can tell me what it is I'll install it.
 

Dannz

New Member
Messages
43
Reaction score
0
Points
0
Hi Corey - there seems to be a problem with MySQLdb - this is a Python module which provides an api to MySQL for Python (i.e. can use a Python cgi script to database queries etc.) The module was installed a few of months back, but now doesn't seem to be working. Perhaps the easiest would be a new install. The module is available at sourceforge:

http://sourceforge.net/projects/mysql-python

If you can post here when installed I'll test it out and confirm its all working ok if you like.

Hi Korexio - No other way to access MySQL using Python at the moment - there are other Python modules to do this, but these aren't installed. The MySQLdb seems the best from what I could gather, and it worked nicely on the server before this glitch. Hopefully when reinstalled it will be running as nice and sweetly as before.
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
205
Points
63
I have installed this module, let me know if it is working.

-Corey
 

Korexio

New Member
Messages
5
Reaction score
0
Points
0
still not working ...

no, it's still not working, but thanks for the effort!

Test-Script:
http://platypus.x10hosting.com/imp/test.py

Code:
PHP:
#!/usr/local/bin/python

print "Content-type: text/plain\n\n"

try:
....import MySQLdb
except Exception, e:
....print e


=> blank page means success.
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
I've made some changes and reinstalled it, it looks like it is working now.

Do you need any further help?
 

Korexio

New Member
Messages
5
Reaction score
0
Points
0
Works now, great!

It works now, thanks a lot, really really great support! :lol:

I could write a short introduction in how to use python on your hosting platform, if you would be interested?
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
205
Points
63
If you want to create a thread in the tutorials section that might help some other users interested in using it. Since this is solved I'm going to close it out now. Please re-open if further assistance is needed.
 
Status
Not open for further replies.
Top