Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Larry Martell Newsgroups: comp.lang.python Subject: Re: How to connect the MYSQL database to Python program? Date: Fri, 11 Dec 2015 13:51:46 -0500 Lines: 30 Message-ID: References: <9261e7b4-48ad-45f2-ba65-066177d21f6b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de +ISQbzLqV07oGCF6d72p0gxg4bg6mCO2+1qQTEFPHTvw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'wednesday,': 0.07; 'subject:How': 0.09; 'python': 0.10; 'thu,': 0.15; 'db)': 0.16; 'program?': 0.16; 'pypi.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:program': 0.16; 'wrote:': 0.16; 'module,': 0.18; '2015': 0.20; 'to:name:python-list@python.org': 0.20; 'correctly.': 0.22; 'am,': 0.23; 'dec': 0.23; 'this:': 0.23; 'import': 0.24; 'header :In-Reply-To:1': 0.24; 'module': 0.25; 'installed': 0.26; 'chris': 0.26; 'skip:m 30': 0.27; 'fri,': 0.27; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'connection': 0.30; 'that.': 0.30; 'code': 0.30; 'december': 0.32; 'lets': 0.33; 'open': 0.33; 'received:google.com': 0.35; 'done': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'user,': 0.67; 'chrisa': 0.84; 'ict': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=XACjrCYWx+fYgh7cpH1nDmoTEEd/G0RTqST3sNke+o4=; b=GMCMRESEeGPoU2/8iLOJeLC78+Ho55tVhgw9Y+uWArzmQURqXJTctj7WdYv0bptS+y 9vbbVpVLLAbX8qsFAZndpjizEQXatgmA1vuZ5apbR6j1WRGsIo7l6z17tH5SDJE9DwJ6 7D016zLsh1d7oO2Wwcz5o/6cLERzuMCobMMYxrZ+8rxiExYtj5GAxnnhOOa/IQ+4LF5s X0pgvSWnkGDwkoQWr4w6DqSr6cvznub/XbG/bpSC5hWoQXGcBYUp2w22cYMvDxjjiaKV 2+B4zAzKxpzjhTEaxizYzzGjwwg0Wl0pl828ce0kZhmJJiE6pusOs6DN7HqKbAi+FlEJ Y6pA== X-Received: by 10.107.28.144 with SMTP id c138mr18471041ioc.15.1449859946644; Fri, 11 Dec 2015 10:52:26 -0800 (PST) In-Reply-To: <9261e7b4-48ad-45f2-ba65-066177d21f6b@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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100293 On Fri, Dec 11, 2015 at 1:36 PM, ICT Ezy 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 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")