Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27133

Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host

From nepaul <xs.nepaul@gmail.com>
Newsgroups comp.lang.python
Subject Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host
Date 2012-08-15 18:52 -0700
Organization http://groups.google.com
Message-ID <7c2f8e49-e15f-43c5-8488-70309c08a4da@googlegroups.com> (permalink)
References <6a5212e3-4ff9-4cec-afe5-8b81e231eb67@googlegroups.com> <502bba24$0$6979$e4fe514c@news2.news.xs4all.nl> <878vdgp4c6.fsf@dpt-info.u-strasbg.fr> <mailman.3320.1345049888.4697.python-list@python.org>

Show all headers | View raw


在 2012年8月16日星期四UTC+8上午12时58分07秒,Dennis Lee Bieber写道:
> On Wed, 15 Aug 2012 17:22:49 +0200, Alain Ketterlin
> 
> <alain@dpt-info.u-strasbg.fr> declaimed the following in
> 
> gmane.comp.python.general:
> 
> 
> 
> > Hans Mulder <hansmu@xs4all.nl> writes:
> 
> > 
> 
Right!
> > > On 15/08/12 15:30:26, nepaul wrote:
> 
> > >> The code:
> 
> > >> import MySQLDB
> 
> > >> strCmd = "user = 'root', passwd = '123456', db = 'test', host = 'localhost'"
> 
> > >> 
> 
> > >> 
> 
> > >> 
> 
> > >> _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'user = 'root',
> 
> > >> passwd = '123456', db = 'test', host = 'localhost'' (11004)")
> 
> > >
> 
> > > This message means that the MySQL connector cannot find 'localhost'.
> 
> > 
> 
> > No, it means that connect received a single string "user = 'root'..."
> 
> > instead of a set of individual keyword parameters, and took the whole
> 
> > string to be the name of the host (its first parameter). Of course,
> 
> > there is no host with such a name.
> 
> > 
> 
> > The solution is to parse the string into individual values, and pass
> 
> > these in the correct order.
> 
> 
> 
> 	MySQLdb code itself recommends to always use keyword parameters, so
> 
> the order shouldn't be significant... (and when one sees the list of
> 
> optional keywords, using null commas to space positional arguments would
> 
> be insane)
> 
> 
> 
> 	Parsing that string into separate fields (preferably a dictionary so
> 
> **conectitems could be used) OTOH is critical.
> 
> 
> 
> -- 
> 
> 	Wulfraed                 Dennis Lee Bieber         AF6VN
> 
>         wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 06:30 -0700
  Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-15 15:23 +0100
    Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 07:53 -0700
    Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 07:53 -0700
  Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host Hans Mulder <hansmu@xs4all.nl> - 2012-08-15 17:02 +0200
    Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-08-15 17:22 +0200
      Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 09:50 -0700
      Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-15 12:58 -0400
        Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 18:52 -0700
        Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host nepaul <xs.nepaul@gmail.com> - 2012-08-15 18:52 -0700

csiph-web