473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

OperationalError: (2005, "Unknown MySQL server host 'host' (11004)")

for the code below i got error:


Traceback (most recent call last):
File "C:/Python26/testdb", line 6, in <module>
db = MySQLdb.connect("host","testuser","test123","TESTD B" )
File "C:\Python26\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line 170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2005, "Unknown MySQL server host 'host' (11004)")


Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/python
  2.  
  3. import MySQLdb
  4.  
  5. # Open database connection
  6. db = MySQLdb.connect("host","testuser","test123","TESTDB" )
  7.  
  8. # prepare a cursor object using cursor() method
  9. cursor = db.cursor()
  10.  
  11. # Drop table if it already exist using execute() method.
  12. cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
  13.  
  14. # Create table as per requirement
  15. sql = """CREATE TABLE EMPLOYEE (
  16.          FIRST_NAME  CHAR(20) NOT NULL,
  17.          LAST_NAME  CHAR(20),
  18.          AGE INT,  
  19.          SEX CHAR(1),
  20.          INCOME FLOAT )"""
  21.  
  22. cursor.execute(sql)
  23.  
  24. # disconnect from server
  25. db.close()
Jul 20 '10 #1
0 2725

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jim the Bad | last post by:
Hi, I wonder if anyone can help me with this. Bog standard SuSE 8.2 Linux install. I have installed mySQL (off the SuSE 8.2 distro CDs). I can connect locally, e.g: bealzebub> mysql -u root...
0
by: MLH | last post by:
I used the following SQL to create a new table in a database on a remote MySQL server by copying one already there. I know the table exists SOMEWHERE in cyberspace. I can read its data, write to...
2
by: Asad Khan | last post by:
Hello, I was using MySQL till a few days ago just fine. Now everytime I try to run it using mysql.exe, I get the following error: "can't connect to mysql server 'localhost' (10061)" What...
1
by: JW | last post by:
Hi all, I was fine running mysql, and for some reason, after the most recent reboot of my machine, I get the following error and I try the following subsequent commands to try to figure things...
2
by: Mike Hofer | last post by:
In my ASP.NET application, *one* page would not render in the application. All others would show up just fine, but when the user clicked the button to browse to this one page, I'd get a nasty error...
2
by: Misbah M Hasan | last post by:
Hi, I have developed and ASP.NET web-based application and ofcourse, I have created a virtual directory. I can access my developed web-application from my machine (i.e. locally); but unable to...
2
by: =?Utf-8?B?QnJlbnQgUm9nZXJz?= | last post by:
I have a asp page that does a Respnse.Redirect() and sometimes I keep getting a "Cannot find server or DNS Error" . I have validated that the URL being redirected to is valid. The URL...
4
by: Atrisa | last post by:
I have a file with lines like this: Host: gateway.edge.messenger.live.com Referer: 13.gateway.edge.messenger.live.com/help Host: ads.lfstmedia.com Referer:...
2
by: Suzanne Montz | last post by:
I am working in Talend Open Profiler software, and checking tables in Navicat Lite. A few days ago, one of the created MySQL servers gave the message error 2003 - Can't connect to MySQL server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.