Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8232311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:47:31+00:00 2026-06-07T17:47:31+00:00

I am working with MySQL-python package. I am able to execute MySQL dependent scripts

  • 0

I am working with MySQL-python package. I am able to execute MySQL dependent scripts from command line, however doing the same through browser (Apache CGI) yields the following error:

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.  
/var/www/html/temp.py in ()  
9 
10 # Establich a connection
11 db = MySQLdb.connection(host="127.0.0.1", user="root", passwd="", db="inserv")
12 
13 # Run a MySQL query from Python and get the result set  
   db undefined, MySQLdb = <module 'MySQLdb' from 
  '/usr/lib64/python2.6/site-packages
/MySQLdb/__init__.pyc'>, MySQLdb.connection = <type '_mysql.connection'>,  
host undefined,   user undefined, passwd undefined

<class '_mysql_exceptions.OperationalError'>: 
(2003, "Can't connect to MySQL server on '127.0.0.1' (13)")
  args = (2003, "Can't connect to MySQL server on '127.0.0.1' (13)")
  message = '' 

I have been stuck in this situation for past few days. MySQL commands issued through php based sites execute appropriately and I can, also, login to MySQL from command line. The problem seem to be with Python CGI only.

I have also tried the same with oursql package and there seems to be a similar problem. How can I address this situation?

Edit
As per @Real’s answer I have edited my code to use MySQLdb.connect() but the problem still persist and traceback ends with:

2003, "Can't connect to MySQL server on '127.0.0.1' (13)"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T17:47:33+00:00Added an answer on June 7, 2026 at 5:47 pm

    You should be using connect, not connection. Mysqldb.connect() returns a connection object but you appear to be calling mysqldb.connection(). See The docs for an example of how to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get MySQL working with Python, but I haven't been able
My insert and update pages (through my admin forlder) into mysql stopped working. When
Whilst writing working my way through a list of scripts I need to write
I want to get MySQL working with the system Python 2.7 in Mac OS
Working with cursors in mysql-python I used to call BEGIN;, COMMIT;, and ROLLBACK; explicitly
I am using django-1.2 and python-2.6 and I am using mysql server. After working
I am working with Python MySQL, and need to clean a table in my
I am currently working on a python script that pulls data from a table
I'm having difficulty getting MySQLdb working for: OSX 10.7.3 Python 2.7.1 (64-bit) MySQL 5.1.62-osx10.6-x86_64
Any idea why the following code is not working mysql credentials are correct, have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.