Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65656

Re: Why use _mysql module and not use MySQLdb directly?

References <f3632548-db57-4357-8d01-03807861d851@googlegroups.com>
Date 2014-02-08 20:00 +1100
Subject Re: Why use _mysql module and not use MySQLdb directly?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6530.1391850062.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sat, Feb 8, 2014 at 7:52 PM, Sam <lightaiyee@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Why use _mysql module and not use MySQLdb directly? Sam <lightaiyee@gmail.com> - 2014-02-08 00:52 -0800
  Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 20:00 +1100
  Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 03:09 -0800
    Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 22:25 +1100
      Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 03:32 -0800
        Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 22:42 +1100
          Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 04:09 -0800
            Re: Why use _mysql module and not use MySQLdb directly? Marcel Rodrigues <marcelgmr@gmail.com> - 2014-02-09 08:40 -0200

csiph-web