How to get python connect to database example to work?

Category: Website

brenner
Asked:
2011-11-11 12:25 pm EST

Hits: 9,676
You have en example in your support center entitled "How to use Python to connect to a database" and I do not understand how to get the example python file within it to run. I have placed the .py file in the cgi-bin folder as directed.

In one spot, it is stated that
"When viewing this page in our browser, we see:

Database version : 5.0.92-community-log"
but I can't view it in my browser. In fact, for any file in the cgi-bin folder I get an internal server error when I navigate to it.

I hope I am correct in actually navigating to the .py file as it looks as though it is supposed to act like an html file based on the print statements at the bottom.

I have tried changing the file extension to .cgi as suggested by some help sites, but that has not helped either.

Any suggestions on how to make it so that browsers execute the .py file and interpret the printed results as html would be greatly appreciated.

Also it seems odd that the python file should go in the cgi-bin folder if it is supposed to act like an html page. Suppose you wanted the .py file to be your index file. Would it recognize it as one?

Thanks,
Eric

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by InMotion Hosting staff

0

Tim S.
Staff
9,967 Points
2011-11-11 12:46 pm EST
Hi brenner,

Thanks for posting your question. I'm more than happy to assist you today. I looked over your account and did not see the test script so I could troubleshoot it. Have you removed the script?

Also, you'll need to create a database and user, then attach the user to the database. Here's an article explaining how to to that:

Creating a Database in CPanel

Also, once the script is uploaded to the cgi-bin, you'll need to change the file permissions to 0755.

If you need further assistance please feel free to contact us.

Thanks!

Tim S

You must login before you can post a comment about this answer.

Like this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!