Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'url:sourceforge': 0.03; 'postgresql,': 0.09; 'subject:Why': 0.09; 'subject:module': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'api,': 0.16; 'directly?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'normally,': 0.16; 'sat,': 0.16; 'ignore': 0.16; 'language': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'instead.': 0.24; 'prototype': 0.24; 'fairly': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'purposes': 0.26; 'switch': 0.26; 'header :In-Reply-To:1': 0.27; '(like': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'another': 0.32; 'maybe': 0.34; 'received:google.com': 0.35; 'really': 0.36; 'module.': 0.36; 'subject:?': 0.36; 'similar': 0.36; 'changing': 0.37; 'level': 0.37; 'easily': 0.37; 'pm,': 0.38; 'around.': 0.60; 'most': 0.60; "you're": 0.61; 'first': 0.61; 'direct': 0.67; 'close': 0.67; 'sam': 0.68; 'superior': 0.69; 'to:none': 0.92 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=rpdygim7uvMOpJhJ9xYKxv4eaMhBqz1WgoKKnw0QMAo=; b=an7kPCvYFHJ+hotCp7YwofSxId0WQv0xrAdCcyTEZ20pwRq5T3O77uF4ff0m8Da0Ne cn2z9e2sC2JtYycvCZTqEtWiOYeY+BGRV9SyMFrZtcRLl0eKKXROghtvVZkWLV4M7y+D QnhkUiAQER+0zSXCjfYwZMSbLuWS0xmEI1J9iHnuDVo6p5hCDXEcU2006uu7vtpR6b9/ PkhEV6z8mmW7ZQAXiVWJ34Q7tTyp0x0uu2fh/XSclkpeMC95xtaaD8wYyjhPJnJIUZXQ udSNtcd4TfHa2/NHOjOLciI4kOAKa8V6GN/0FsXsWPKjaurS7IB4LZMK4D6jBqYymPko M+Mg== MIME-Version: 1.0 X-Received: by 10.68.51.39 with SMTP id h7mr24976009pbo.101.1391850058635; Sat, 08 Feb 2014 01:00:58 -0800 (PST) In-Reply-To: References: Date: Sat, 8 Feb 2014 20:00:58 +1100 Subject: Re: Why use _mysql module and not use MySQLdb directly? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391850062 news.xs4all.nl 2958 [2001:888:2000:d::a6]:57157 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65656 On Sat, Feb 8, 2014 at 7:52 PM, Sam wrote: > I am writing my first python script to access MySQL database. With reference to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects > > Why is it advisable to use _mysql and not MySQLdb module directly? Other way around. It's advisable to ignore _mysql, which is a fairly direct representation of the MySQL C API, and use MySQLdb instead. When you use MySQLdb, you can fairly easily switch over to another database engine (like PostgreSQL, which for most purposes is superior to MySQL anyway), without changing most of your code. The only reason to use _mysql would be if you need your code to be really similar to other MySQL code in some other language - maybe you're using Python to prototype a C application, and want to keep everything as close as you can. Normally, use the higher level module. ChrisA