How to connect the MYSQL database to Python program?

ICT Ezy ictezy at gmail.com
Fri Dec 11 14:11:27 EST 2015


On Friday, December 11, 2015 at 10:52:49 AM UTC-8, Larry.... at gmail.com wrote:
> On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy <ictezy at 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 at 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")

Ok Larry, I have success now, my names are misspelling. work well



More information about the Python-list mailing list