Menu

#123 select_db method do not work

MySQLdb-1.0
closed
MySQLdb (285)
5
2012-09-19
2005-01-14
Anonymous
No

The select_db method do not work in MySQLdb-1.0 with
python 2.4

I was using the same script with MySQLdb-0.9.2 with
Python 2.3 and it was working.

Discussion

  • Andy Dustman

    Andy Dustman - 2005-01-15

    Logged In: YES
    user_id=71372

    So... what does it do now? Post or attach a test case.

     
  • Nobody/Anonymous

    Logged In: NO

    Please find the test case:

    PythonWin 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32
    bit (Intel)]
    on win32.
    Portions Copyright 1994-2004 Mark Hammond
    (mhammond@skippinet.com.au) - see 'Help/About PythonWin'
    for further copyright information.

    import MySQLdb
    c = MySQLdb.connect(user = 'root', db = 'flamenco')
    cursor = c.cursor()
    cursor.execute('Show Databases')
    4L
    cursor.fetchone()
    ('flamenco',)
    c.select_db('tango')
    cursor.execute('Show Databases')
    4L
    cursor.fetchone()
    ('flamenco',)

     
  • Andy Dustman

    Andy Dustman - 2005-01-18

    Logged In: YES
    user_id=71372

    What do you think the output should be here? Looks like it's
    working to me. SHOW DATABASES shows what databases exist,
    not which one you are using. Your example does not
    demonstrate anything relevant.

     
  • Nobody/Anonymous

    Logged In: NO

    Sorry the output shows that the select_db() do not work.

    After the c.select_db('tango'), the show database show that
    the database is still flamenco while it should be egal to tango.

    In my humble opinion, the select_db method do not work
    because the example show no return value.

     
  • Andy Dustman

    Andy Dustman - 2005-01-19

    Logged In: YES
    user_id=71372

    No.

    It's "show databaseS" (what databases exist), not "show
    database" (what database am I using). Try c.fetchall()
    instead of c.fetchone() and you'll see why you are wrong.
    Also, db.select_db(dbname) is not supposed to return
    anything, because mysql_select_db(dbname) only returns an
    error code.

     
  • Nobody/Anonymous

    Logged In: NO

    Your are right. I tested again and it works correctly. Thanks
    for your help.

     

Log in to post a comment.