MySQL with Python

Discussion in 'Python' started by রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€, Oct 15, 2012.

  1. Dear friends,
    I am starting a project of creating a database using mySQL(my first
    project with database).
    I went to my institute library and find that, all books are managing
    "mySQL with perl and php"

    I am new to python itself and gradually loving it. I mostly use it as an
    alternative of shell-script. Since learning a new language for every new
    project is not possible(its self assigned project, generally in free
    time), can I do a "mySQL with python?"

    if yes, can you kindly suggest a book/reference on this?
    রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€, Oct 15, 2012
    #1
    1. Advertising

  2. On Tue, Oct 16, 2012 at 12:45 AM, রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€ <> wrote:
    > Dear friends,
    > I am starting a project of creating a database using mySQL(my first
    > project with database).
    > I went to my institute library and find that, all books are managing
    > "mySQL with perl and php"
    >
    > I am new to python itself and gradually loving it. I mostly use it as an
    > alternative of shell-script. Since learning a new language for every new
    > project is not possible(its self assigned project, generally in free
    > time), can I do a "mySQL with python?"
    >
    > if yes, can you kindly suggest a book/reference on this?


    It's definitely possible. As far as I know, though, there's no inbuilt
    support, so you'll need an add-on module. What platform are you
    running on? On Debian Linux, for instance, you can simply "apt-get
    install python-mysqldb".

    But you may wish to consider using PostgreSQL instead. It's a
    generally better database engine than MySQL, and is equally well
    supported:

    http://wiki.python.org/moin/PostgreSQL

    Actually, to be quite honest, I'm surprised there's no module in the
    Python stdlib for either of the above. Possibly because there are
    several competing options.

    ChrisA
    Chris Angelico, Oct 15, 2012
    #2
    1. Advertising

  3. On 12-10-15 06:45 AM, রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€ wrote:
    > if yes, can you kindly suggest a book/reference on this?
    >


    There are a few different ways to connect to MySQL, two of which are:

    For reference on connecting and querying MySQL through mysql-python,
    take a read through http://mysql-python.sourceforge.net/MySQLdb.html.

    Another solution is to use SQLAlchemy (http://www.sqlalchemy.org/). The
    ORM abstracts a lot of the tedious SQL queries out for you and allows
    you to concentrate more on your application's logic.

    --
    Demian Brecht
    @demianbrecht
    http://demianbrecht.github.com
    Demian Brecht, Oct 15, 2012
    #3
  4. On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote:
    > But you may wish to consider using PostgreSQL instead.

    Thanks, as I am very much new in database thing, I am not very aware of
    the options I have.
    But in my library, I did not found any thing on PostgreSQL.
    Though, I will google its support as well, can you kindly let me know if
    this is well documented. I can see there mailing list is quite active.
    So that may not be a problem though.
    রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€, Oct 15, 2012
    #4
  5. On Tue, Oct 16, 2012 at 1:47 AM, রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€ <> wrote:
    > On Tue, 2012-10-16 at 01:01 +1100, Chris Angelico wrote:
    >> But you may wish to consider using PostgreSQL instead.

    > Thanks, as I am very much new in database thing, I am not very aware of
    > the options I have.
    > But in my library, I did not found any thing on PostgreSQL.
    > Though, I will google its support as well, can you kindly let me know if
    > this is well documented. I can see there mailing list is quite active.
    > So that may not be a problem though.


    Postgres itself: http://www.postgresql.org/

    I posted a link to some Python-PGSQL libraries in my previous post.

    ChrisA
    Chris Angelico, Oct 15, 2012
    #5
  6. On Mon, 15 Oct 2012 14:45:32 +0100, ????? ??????????
    <> declaimed the following in
    gmane.comp.python.general:

    > Dear friends,
    > I am starting a project of creating a database using mySQL(my first
    > project with database).
    > I went to my institute library and find that, all books are managing
    > "mySQL with perl and php"
    >
    > I am new to python itself and gradually loving it. I mostly use it as an
    > alternative of shell-script. Since learning a new language for every new
    > project is not possible(its self assigned project, generally in free
    > time), can I do a "mySQL with python?"
    >
    > if yes, can you kindly suggest a book/reference on this?


    First off, how much "managing" do you expect to perform? For
    actually managing the MySQL server you're probably better off
    downloading the dedicated application (Used to be "MySQL Admin" and a
    separate "MySQL QueryBrowser" -- the current download is a unified
    "MySQL Workbench").

    For routine database /access/ (that is, someone has created the
    database user account that will be used), MySQLdb is the Python adapter
    to connect to the server. For using THAT, you basically need to know SQL
    (MySQL's flavor in particular), along with understanding the DB-API 2
    specification (PEP-249) with the MySQLdb documentation (which explains
    any limitations or specifics; see http://mysql-python.sourceforge.net/ )

    For books, though some are rather old by now:

    MySQL for Python
    (Albert Lukaszewski; 2010 Packt Publishing)

    The Definitive Guide to MySQL 5 3rd Ed
    (Michael Kofler; 2005 Apress)[no Python chapter, but does introduce the
    now-discontinued Admin and QueryBrowser applications, and introduces the
    features of MySQL v5

    Managing & Using MySQL 2nd Ed (Reese/Yarger/King; 2002 O'Reilly)[has 5
    pages on MySQL with Python]

    And a new edition NOT YET RELEASED -- don't know if this edition
    includes anything on Python, the 3rd edition does not; but the volume is
    huge and may be close to covering what the old MySQL AB "Administrators
    Guide" and "Language Reference" books covered.

    MySQL 5th Ed
    (Paul DuBois; Dec 2012 Addison-Wesley [Developer's Library])
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Oct 15, 2012
    #6
  7. রà§à¦¦à§à¦° বà§à¦¯à¦¾à¦£à¦¾à¦°à§à¦œà§€

    Roy Smith Guest

    In article <>,
    Dennis Lee Bieber <> wrote:

    > For routine database /access/ (that is, someone has created the
    > database user account that will be used), MySQLdb is the Python adapter
    > to connect to the server. For using THAT, you basically need to know SQL
    > (MySQL's flavor in particular), along with understanding the DB-API 2
    > specification (PEP-249) with the MySQLdb documentation (which explains
    > any limitations or specifics; see http://mysql-python.sourceforge.net/ )


    Another possibility is to use some sort of ORM (Object Relational
    Mapper), which provides an abstraction layer on top of the raw SQL
    layer. Two examples are SQLAlchemy (http://www.sqlalchemy.org/) and
    Django (https://www.djangoproject.com/).

    A thread on Stack Overflow (http://stackoverflow.com/questions/53428)
    mentions some additional Python ORMs you might want to explore.
    Roy Smith, Oct 15, 2012
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JL
    Replies:
    0
    Views:
    1,133
  2. Ravi
    Replies:
    6
    Views:
    1,393
    Suchandra Thapa
    Jul 21, 2003
  3. Replies:
    2
    Views:
    6,172
  4. washakie
    Replies:
    4
    Views:
    907
    washakie
    Jan 15, 2008
  5. dave
    Replies:
    4
    Views:
    1,350
    Steve Holden
    Nov 18, 2010
Loading...

Share This Page