FAQ
Hello,
i tried to find something about mysql in www.python.org, but found
nothing...
What can you recommend to use for getting and putting data from and into a
mysql database?
On my Suse 9.1 i found a rpm python-mysql. In the web i found the hk_classes
from www.knoda.org. This should do also such things.
Can you recommend something? What do you use?
Thank you very much for the info.
--
Gr?sse/Greets
Stolz Stefan

Search Discussions

  • Jeremy Jones at Aug 26, 2004 at 6:05 pm

    Stefan Stolz wrote:
    Hello,
    i tried to find something about mysql in www.python.org, but found
    nothing...
    What can you recommend to use for getting and putting data from and into a
    mysql database?
    On my Suse 9.1 i found a rpm python-mysql. In the web i found the hk_classes
    from www.knoda.org. This should do also such things.
    Can you recommend something? What do you use?
    Thank you very much for the info.
    I have used a MySQLdb module before. Here's a piece of code that I
    found lying around my home directory:

    import MySQLdb

    if __name__ == "__main__":
    db_conn =
    MySQLdb.connect(host='hostname',db='database_name',user='username',passwd='password')
    handle = db_conn.cursor()
    query = "SELECT * FROM foo"
    handle.execute(query)
    Results = handle.fetchall()
    print Results

    I'm not sure, but I believe that MySQLdb is included in this project:

    http://sourceforge.net/projects/mysql-python

    (which appears to have been updated only a couple of months back, so
    that's good news).
  • Stefan Stolz at Aug 26, 2004 at 6:16 pm

    Jeremy Jones wrote:

    I'm not sure, but I believe that MySQLdb is included in this project:

    http://sourceforge.net/projects/mysql-python

    (which appears to have been updated only a couple of months back, so
    that's good news).
    Thank you, but i don`t understand why there is nothing implemented in
    Python?

    I was a little konfused after reading the doku of mysql-python, because
    there the author says its better to use MySQLdb ;-) ?!?!
    --
    Gr?sse
    Stolz Stefan
  • Jeremy Jones at Aug 26, 2004 at 6:42 pm

    Stefan Stolz wrote:
    Jeremy Jones wrote:


    I'm not sure, but I believe that MySQLdb is included in this project:

    http://sourceforge.net/projects/mysql-python

    (which appears to have been updated only a couple of months back, so
    that's good news).
    Thank you, but i don`t understand why there is nothing implemented in
    Python?

    I was a little konfused after reading the doku of mysql-python, because
    there the author says its better to use MySQLdb ;-) ?!?!
    So, are you wanting a pure Python module to connect to MySQL? I'm not
    sure there are any that exist.

    Jeremy
  • Yann.K at Aug 26, 2004 at 7:43 pm

    Jeremy Jones wrote:

    I was a little konfused after reading the doku of mysql-python, because
    there the author says its better to use MySQLdb ;-) ?!?!
    So, are you wanting a pure Python module to connect to MySQL? I'm not
    sure there are any that exist.
    10 seconds with google and maybe some leads:
    http://www.hk8.org/old_web/linux/sql/ch11_01.htm
    http://mysql.mirror.nedlinux.nl/downloads/python.html
    http://linux.maruhn.com/sec/mysql-python.html
    http://linux.com.hk/docs/mysql/manual_Clients.html#IDX2125

    HTH.

    --
    Yann.K
  • Simon John at Aug 26, 2004 at 6:45 pm
    Probably the only thing keeping me with database coding in PHP instead
    of Python is that it's so unclear what should be used for what!

    It's a similar thing for templating systems - there's too much choice,
    and nothing has really become "the standard". I never thought I'd
    complain about too much choice!

    Also, PostgreSQL seems to be better supported than MySQL, although good
    luck finding a web host with PostgreSQL *and* mod_python!

    I guess anything that uses the DB-API 2 should be used, but MySQLdb
    says it's out-of-date!

    There's a list of modules at
    http://python.org/topics/database/modules.html
  • Jonathan Daugherty at Aug 26, 2004 at 7:05 pm
    # Also, PostgreSQL seems to be better supported than MySQL, although
    # good luck finding a web host with PostgreSQL *and* mod_python!

    Hey,

    Command Prompt provides web hosting and we only support PostgreSQL.
    We'd be glad to provide mod_python.

    http://www.commandprompt.com

    --
    Jonathan Daugherty
    http://www.cprogrammer.org
  • JZ at Aug 27, 2004 at 8:04 am

    26 Aug 2004 11:45:12 -0700, na comp.lang.python, Simon John napisa?(a):

    Probably the only thing keeping me with database coding in PHP instead
    of Python is that it's so unclear what should be used for what!
    Using PHP native database functions is a very bad idea. All experencied
    programmers use more abstract db wrappers like ADOdb
    (http://adodb.sourceforge.net/). There is ADOdb version for Python as well.
    Other pythonic modules are DB-API2 compatible so there is no such mess like
    PHP native functions.
    It's a similar thing for templating systems - there's too much choice,
    and nothing has really become "the standard". I never thought I'd
    complain about too much choice!
    There is no PHP standard templating system. PHP itself is a template
    framework! (although no one experienced want to use its mixing php and html
    mess). Check ezPublish, Invision Board, phpBB or others bigger projects. No
    one keep with one, standard template framework.

    --
    JZ
  • Simon John at Aug 27, 2004 at 5:56 pm

    Paul Rubin wrote:

    Using PHP native database functions is a very bad idea. All
    experencied
    programmers use more abstract db wrappers like ADOdb
    (http://adodb.sourceforge.net/).
    Interesting. Every PHP app I've ever seen uses the native functions,
    but I haven't looked at many fancy ones.
    Yeah, same here, I've always just used the Oracle or MySQL native
    functionality, and wouldn't call myself unexperienced! I've just never
    had the need for a database abstraction layer (it's always been
    clear-cut what database I will use, and stick with).
    There is no PHP standard templating system. PHP itself is a
    template
    framework!
    I'm not sure what the distinction is supposed to be?
    PHP4 has it's own templating system (allowing repeatable blocks etc)
    things like Nuke are more advanced, like a CMS. I prefer the more basic
    functionality that I can control better myself, rather than having to
    work to a spec enforced by third-party software.

    And the ADOdb page says that to use it with MySQL, you have to install
    the mysql-python (MySQLdb) module, so doesn't really help here, as we
    haven't even got that far!
  • JZ at Aug 27, 2004 at 9:55 pm

    Dnia 27 Aug 2004 10:56:13 -0700, Simon John napisa?(a):

    And the ADOdb page says that to use it with MySQL, you have to install
    the mysql-python (MySQLdb) module, so doesn't really help here, as we
    haven't even got that far!
    But what's the real problem? Everyone knows MySQLdb is the main MySQL
    module for Python...

    --
    JZ
  • Simon John at Aug 27, 2004 at 10:24 pm
    I got MySQLdb working with MySQL4, it's pretty similar to the PHP
    implementation, although error handling isn't great (nor is
    documentation!)

    I'm going to look at the ADOdb wrapper, which has the DB-API2
    documentation to go with it, and some error handling outside of just
    try...except
  • Ludovico Magnocavallo at Aug 29, 2004 at 12:01 am

    Simon John wrote:
    I got MySQLdb working with MySQL4, it's pretty similar to the PHP
    implementation, although error handling isn't great (nor is
    documentation!)
    What are you finding "not great" in MySQLdb's error handling? It
    implements the exceptions defined in the DB-API, which I find way better
    than PHP's mysql_errno() and friends:

    try:
    cursor.execute(some_statement)
    except MySQLdb.IntegrityError, e:
    # handle a specific error condition
    except MySQLdb.Error, e:
    # handle a generic error condition
    except MySQLdb.Warning, e:
    # handle warnings, if the cursor you're using raises them

    What can be simpler than that? Or do you prefer PHP's way, which gives
    you no direct, portable way of knowing what kind of error was returned
    by the DB:

    $result = mysql_query($statement, $connection);
    if (!$result) {
    $error = mysql_error();
    $errno = mysql_errno();
    // $error and $errno are mysql-specific
    }

    Ludo
  • JZ at Aug 27, 2004 at 6:07 pm

    Dnia 27 Aug 2004 01:14:40 -0700, Paul Rubin napisa?(a):

    There is no PHP standard templating system. PHP itself is a template
    framework!
    I'm not sure what the distinction is supposed to be?
    From the beginning PHP was invented to be a template language (similar like
    today Smarty is a "template language" for today's php) First PHP was no
    object language at all. It's history was adding more and more functions,
    sessions, first poor object features etc, etc.

    --
    JZ

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 26, '04 at 5:48p
activeAug 29, '04 at 12:01a
posts13
users8
websitepython.org

People

Translate

site design / logo © 2022 Grokbase