Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'arguments': 0.07; 'parsing': 0.07; '(its': 0.09; 'alain': 0.09; 'positional': 0.09; 'recommends': 0.09; 'to:addr:comp.lang.python': 0.09; 'used)': 0.09; 'cc:addr:python-list': 0.10; 'aug': 0.13; '"unknown': 0.16; '"user': 0.16; "'test',": 0.16; 'parameters,': 0.16; 'sees': 0.16; 'wed,': 0.16; 'string': 0.17; 'wrote:': 0.17; "shouldn't": 0.17; 'import': 0.21; 'keywords,': 0.22; 'parse': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'host': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'order.': 0.27; 'separate': 0.27; 'correct': 0.28; 'dictionary': 0.29; 'optional': 0.29; 'subject:: (': 0.29; 'writes:': 0.29; 'no,': 0.29; 'keyword': 0.30; 'code': 0.31; '(and': 0.32; 'could': 0.32; 'skip:_ 30': 0.32; '+0200,': 0.33; 'null': 0.33; 'url:home': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'server': 0.35; 'list': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'itself': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'space': 0.39; 'first': 0.61; '8bit%:60': 0.84; 'subject:skip:_ 30': 0.84; 'dennis': 0.91; 'received:209.85.220.184': 0.91 Newsgroups: comp.lang.python Date: Wed, 15 Aug 2012 18:52:29 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=113.106.106.98; posting-account=gm5T0QoAAADsrQB6lKn4dmNQxJ9E7E9m References: <6a5212e3-4ff9-4cec-afe5-8b81e231eb67@googlegroups.com> <502bba24$0$6979$e4fe514c@news2.news.xs4all.nl> <878vdgp4c6.fsf@dpt-info.u-strasbg.fr> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 113.106.106.98 MIME-Version: 1.0 Subject: Re: _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host From: nepaul To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345082589 news.xs4all.nl 6852 [2001:888:2000:d::a6]:35660 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27134 =E5=9C=A8 2012=E5=B9=B48=E6=9C=8816=E6=97=A5=E6=98=9F=E6=9C=9F=E5=9B=9BUTC+= 8=E4=B8=8A=E5=8D=8812=E6=97=B658=E5=88=8607=E7=A7=92=EF=BC=8CDennis Lee Bie= ber=E5=86=99=E9=81=93=EF=BC=9A > On Wed, 15 Aug 2012 17:22:49 +0200, Alain Ketterlin >=20 > declaimed the following in >=20 > gmane.comp.python.general: >=20 >=20 >=20 > > Hans Mulder writes: >=20 > >=20 >=20 Right=EF=BC=81 > > > On 15/08/12 15:30:26, nepaul wrote: >=20 > > >> The code: >=20 > > >> import MySQLDB >=20 > > >> strCmd =3D "user =3D 'root', passwd =3D '123456', db =3D 'test', hos= t =3D 'localhost'" >=20 > > >>=20 >=20 > > >>=20 >=20 > > >>=20 >=20 > > >> _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server hos= t 'user =3D 'root', >=20 > > >> passwd =3D '123456', db =3D 'test', host =3D 'localhost'' (11004)") >=20 > > > >=20 > > > This message means that the MySQL connector cannot find 'localhost'. >=20 > >=20 >=20 > > No, it means that connect received a single string "user =3D 'root'..." >=20 > > instead of a set of individual keyword parameters, and took the whole >=20 > > string to be the name of the host (its first parameter). Of course, >=20 > > there is no host with such a name. >=20 > >=20 >=20 > > The solution is to parse the string into individual values, and pass >=20 > > these in the correct order. >=20 >=20 >=20 > MySQLdb code itself recommends to always use keyword parameters, so >=20 > the order shouldn't be significant... (and when one sees the list of >=20 > optional keywords, using null commas to space positional arguments would >=20 > be insane) >=20 >=20 >=20 > Parsing that string into separate fields (preferably a dictionary so >=20 > **conectitems could be used) OTOH is critical. >=20 >=20 >=20 > --=20 >=20 > Wulfraed Dennis Lee Bieber AF6VN >=20 > wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/