Reputation: 860
I am trying to run python script and wish to connect python to the mysql on my cpanel based shard hosting.
When i type the following in test.py
inside cgi-bin
folder:
#!/usr/bin/python
print
import MySQLdb
I get an import error. This, to what i assume, that the MySQLdb library is not installed on the hosting server. What is the solution to this issue? How do i manually install this library? Can i externally link to this library?
Upvotes: 0
Views: 367
Reputation: 10315
honestly you will need MySQLdb for any python mysql code. Better consult with your web host.
If you can access to site-packages directory ~/lib/python2.7/site-packages,
then build/install will work
Check if mysqldb installed or not using
#!/usr/bin/python
module_name = 'MySQLdb'
try:
__import__(module_name)
print 'installed'
except ImportError:
print 'not installed'
Upvotes: 1