MySQL from python - dropping a database IF EXISTS

Discussion in 'Python' started by Ben, Dec 4, 2006.

  1. Ben

    Ben Guest

    Can someone explain why this might be happening:

    parser_beta.py:129: Warning: Can't drop database 'foobar'; database
    doesn't exist
    self.cursor.execute("DROP DATABASE IF EXISTS "+name)

    But the whole point about the "IF EXISTS" bit is (I thought) that it
    will only drop it if it exists, if it doesn't do nothing and don't
    throw an error.

    I'm using MySQL 5.024 and python 2.4.3

    It still works, but the unneccesary error is annoying :) Any ideas?

    Cheers,

    Ben
     
    Ben, Dec 4, 2006
    #1
    1. Advertisements

  2. Ben

    Ben Guest

    Re: MySQL from python - dropping a database IF EXISTS

    Ah well - I turned off warnings as a solution. Its a bit f a bodge, but
    it works :)


    Ben wrote:

    > Can someone explain why this might be happening:
    >
    > parser_beta.py:129: Warning: Can't drop database 'foobar'; database
    > doesn't exist
    > self.cursor.execute("DROP DATABASE IF EXISTS "+name)
    >
    > But the whole point about the "IF EXISTS" bit is (I thought) that it
    > will only drop it if it exists, if it doesn't do nothing and don't
    > throw an error.
    >
    > I'm using MySQL 5.024 and python 2.4.3
    >
    > It still works, but the unneccesary error is annoying :) Any ideas?
    >
    > Cheers,
    >
    > Ben
     
    Ben, Dec 4, 2006
    #2
    1. Advertisements

  3. Fredrik Lundh, Dec 5, 2006
    #3
    1. Advertisements

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. Totan
    Replies:
    0
    Views:
    1,305
    Totan
    Apr 17, 2006
  2. Ravi
    Replies:
    6
    Views:
    1,609
    Suchandra Thapa
    Jul 21, 2003
  3. Replies:
    2
    Views:
    6,491
  4. washakie
    Replies:
    4
    Views:
    1,131
    washakie
    Jan 15, 2008
  5. David Härdeman

    Dropping privileges in python daemon

    David Härdeman, Aug 18, 2008, in forum: Python
    Replies:
    1
    Views:
    504
    Matthias Bläsing
    Aug 18, 2008
  6. Replies:
    3
    Views:
    356
    Aaron Brady
    Nov 7, 2008
  7. Ulf Meinhardt
    Replies:
    8
    Views:
    6,641
  8. julian
    Replies:
    8
    Views:
    700
    Avatar
    Apr 6, 2006
Loading...