Python, CGI, MySQL -> 'Error 2004: Can't create TCP/IP socket (10106)'

Doru-Catalin Togea doru-cat at ifi.uio.no
Sat Sep 7 08:57:21 EDT 2002


Hi!

I am using Python 2.2 on a win 2000 Pro computer to interact with mysql,
by means of the MySQLdb module. My non-CGI scripts work as expected. 

I have now installed a webserver (Savant 3.1) am I try to connect to mysql
by means of CGI and still MySQLdb. My scripts fail now with the 'Error
2004: Can't create TCP/IP socket (10106)' error message.

Can anyone tell me what these errors are caused by, and who is it that
generates the error messages? They do not seem to originate from the MySQL
server as it's error checking utility (perror) does not recognize any of
the 2004 or 10106 error codes. Neither did I find any mention of them in
the documentation comming with PythonWin. This leaves me with the theory
that they originate with the web server.

Anyone who can recommand a free webserver which interacts well with MySQL
by means of pythonic CGI scripts on Win 2000 Pro?

What I am trying to do is first to establish a connection to mysql-server
and then to have it execute a sql statement using that connection. 

I have a module called MyDatabase.py. It defines the following functions.	
	
# ********************************************************************
def openDBConnection(h, u, p, d): # host, user, password, database
	try:
		conn = MySQLdb.connect(host = h, user = u, passwd = p, db
= d)
	except MySQLdb.Error, e:
		result = pname + "Error %d: %s" % (e.args[0], e.args[1])
		#sys.exit(1)
		return result
		
	return conn
	
# ********************************************************************
# executes an SQL statement using the given connection
def execSQL(connection, sqlCommand):
	cursor = connection.cursor()
	
	cursor.execute(sqlCommand)	
	rows = cursor.fetchall()
	
	cursor.close()
	return rows
	
These functions work when the script connects to the mysql-server
directly, but fail when a webserver is in between. I call my functions as
follows:
	
import MyDatabase

...
conn = MyDatabase.openDBConnection(host, user, password, database)
sqlCommand = "..."
rows = MyDatabase.execSQL(conn, sqlCommand)
...


Thanks if you can help.

Best regards,
Catalin



	<<<< ================================== >>>>
	<<     We are what we repeatedly do.      >>
	<<  Excellence, therefore, is not an act  >>
	<<             but a habit.               >>
	<<<< ================================== >>>>





More information about the Python-list mailing list