0

I have shared hosting on CentOS with local MySQL database. I'm able to run a simple Python scripts in cgi-bin folder, but I can't make connection to MySQL database. After some google-ing, I found that I need to install some modules or something.. Is there any other way without additional installing, because I don't have admin permissions on the VPS to do that. I have only ftp and Control Panel access to the hosting.

1
  • You don't need admin privileges to include python modules in your own home directory, although installing them via ftp may be more tricky than running setup.py. Commented Mar 19, 2012 at 12:59

1 Answer 1

1

Traditonally, people use the MySQKDB module to acess MySQL from Python. It is possible to build and configure the MySQLDB module for your userif you have acess to the shell and at least GCC instaled there. - just download the tarball, adjust your "prefix" dir for one you have write permissions too, and build it.

Alternatively, tehr eis PyMYSQL (here: https://github.com/petehunt/PyMySQL ) Wwhich is a pure Python module - you shoul dbe able to have it loaded in a directoryyou have access to, and set the Pythonpath environment variable so thta it can be found by your script.

And for last: CGI scripts are rather "20th century" internet - if you want to develop a Python web application or site, I seriously recommend you to move to a provider where you have shell acess, preferably a VPS, and do your project in a modern framework such as django or web2py - you willb e reinventing the wheel several times over developing using CGI, and its performance is as bad as it can be, since it will runa separate instance of the Python interpreter for each incoming http request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.