Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100298
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Igor Korot <ikorot01@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to connect the MYSQL database to Python program? |
| Date | Fri, 11 Dec 2015 14:11:04 -0500 |
| Lines | 62 |
| Message-ID | <mailman.157.1449861067.12405.python-list@python.org> (permalink) |
| References | <a1dc235b-b02e-40c6-adb7-9c280833372b@googlegroups.com> <mailman.98.1449683869.12405.python-list@python.org> <9261e7b4-48ad-45f2-ba65-066177d21f6b@googlegroups.com> <mailman.155.1449859955.12405.python-list@python.org> <a31e76fc-6bf6-4a2c-a916-5e51980080ca@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de RinOiN1qrkWDJJUCandFfAW96n4bIHcvcmNsAWsA90Gw== |
| Return-Path | <ikorot01@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'friday,': 0.07; 'wednesday,': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; '__init__': 0.09; 'python': 0.10; 'python.': 0.11; 'thu,': 0.15; 'db)': 0.16; 'generated,': 0.16; 'program?': 0.16; 'pypi.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'statement.': 0.16; 'subject:program': 0.16; 'wrote:': 0.16; 'module,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '"",': 0.22; 'correctly.': 0.22; 'trying': 0.22; 'am,': 0.23; 'code.': 0.23; 'dec': 0.23; 'this:': 0.23; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'installed': 0.26; 'chris': 0.26; 'skip:m 30': 0.27; 'error': 0.27; 'fri,': 0.27; 'skip:# 10': 0.27; 'message- id:@mail.gmail.com': 0.27; '**kwargs)': 0.29; 'connection': 0.30; 'that.': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'december': 0.32; 'url:python': 0.33; 'lets': 0.33; 'traceback': 0.33; 'open': 0.33; 'url:listinfo': 0.34; "skip:' 20": 0.34; 'file': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'skip:" 50': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'anything': 0.38; 'skip:p 20': 0.38; 'thank': 0.38; 'hi,': 0.38; 'does': 0.39; 'subject:the': 0.39; 'url:mail': 0.40; 'some': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'email addr:gmail.com': 0.62; 'more': 0.63; 'you.': 0.64; 'account': 0.66; 'user,': 0.67; '81,': 0.84; 'chrisa': 0.84; 'ict': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MlksuuTGHbysuVOKq7H8dG/BJbzZcaXPv7P88Flrjes=; b=lnxuysByRbDMoG41L37B6I1OFwdo4kFm1sYShyddtAFAnmPdaFzriYwKP3lEE2l5/v 9RiJgZe4CGGM24Q2k2UJ4xtdQM7+irEJKL+D7KwOX3M/B5HxtWDkZYDWK2yj/fgGzWXM YbTm6Ujr3wPGaZl0z9Zs+xb54+2PUF3l9lVYLMlSuMApXRD9+dMoZ+mvlbZltqyE96SP PJ5H40jL1iv7N6IHOMOz8PtkZbL2fRRuGDoHtHtvYe8cxQpNpRpzO4saxNDNXXefJMJB M5D6Xqze5qNqTyGRN9vp4+Thya0ngp025+SKIcATpchxYpCQBqgQYFeTzSquvNIjrSkR AZOA== |
| X-Received | by 10.31.54.133 with SMTP id d127mr320123vka.126.1449861064956; Fri, 11 Dec 2015 11:11:04 -0800 (PST) |
| In-Reply-To | <a31e76fc-6bf6-4a2c-a916-5e51980080ca@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:100298 |
Show key headers only | View raw
Hi,
On Fri, Dec 11, 2015 at 2:00 PM, ICT Ezy <ictezy@gmail.com> wrote:
> On Friday, December 11, 2015 at 10:52:49 AM UTC-8, Larry....@gmail.com wrote:
>> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy <ictezy@gmail.com> wrote:
>> > On Wednesday, December 9, 2015 at 9:58:02 AM UTC-8, Chris Angelico wrote:
>> >> On Thu, Dec 10, 2015 at 4:51 AM, ICT Ezy <ictezy@gmail.com> wrote:
>> >> > Pl explain me how to connect the MYSQL database to Python program?
>> >>
>> >> You start by looking for a module that lets you do that. You can use
>> >> your favourite web search engine, or go directly to PyPI.
>> >>
>> >> Then you learn how to use that module, including learning SQL if you
>> >> don't already know it.
>> >>
>> >> ChrisA
>> >
>> > Now, I installed MYSQLDB and following code was done correctly.
>> >
>> > #!/usr/bin/python
>> >
>> > import MySQLdb
>> >
>> > # Open database connection
>> > db = MySQLdb.connect("localhost","TESTDB")
>>
>> The connect should look like this:
>>
>> db= MySQLdb.connect(host, user, passwd, db)
>>
>> Or to be clearer:
>>
>> db= MySQLdb.connect(host="localhost", user="user", passwd="password",
>> db="TESTDB")
>
> if there was error generated, i remove password and user
>
>>>> db= MySQLdb.connect(host="localhost", user="testuser", passwd="test123",db="TESTDB")
>
> Traceback (most recent call last):
> File "<pyshell#147>", line 1, in <module>
> db= MySQLdb.connect(host="localhost", user="testuser", passwd="test123",db="TESTDB")
> File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
> return Connection(*args, **kwargs)
> File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 193, in __init__
> super(Connection, self).__init__(*args, **kwargs2)
> OperationalError: (1045, "Acc\xe8s refus\xe9 pour l'utilisateur: 'testuser'@'@localhost' (mot de passe: OUI)")
>>>>
Is the account testuser exist? Does it have a password "test123"?
But more imp[ortantly - this does not have anything to do with Python.
Start by trying to connect from mySQL and try to execute some
insert/update/delete statement.
Then when you succeed, start writing python code.
Thank you.
> pl check it
> --
> https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-09 09:51 -0800
Re: How to connect the MYSQL database to Python program? Chris Angelico <rosuav@gmail.com> - 2015-12-10 04:57 +1100
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:36 -0800
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:39 -0800
Re: How to connect the MYSQL database to Python program? Larry Martell <larry.martell@gmail.com> - 2015-12-11 13:51 -0500
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 11:00 -0800
Re: How to connect the MYSQL database to Python program? Igor Korot <ikorot01@gmail.com> - 2015-12-11 14:11 -0500
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 11:13 -0800
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 11:11 -0800
Re: How to connect the MYSQL database to Python program? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-09 21:42 +0000
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:35 -0800
Re: How to connect the MYSQL database to Python program? ICT Ezy <ictezy@gmail.com> - 2015-12-11 10:39 -0800
csiph-web