Menu

can't connect 2 MySQLdb with zope's python

Help
2005-07-09
2012-09-19
  • isaac martin

    isaac martin - 2005-07-09

    hello everybody
    I've installed mysql-python -v 1.2 with zope's python. Now I've tried to connect to my mysql database by implementing the following code in a pythonscript:

    import MySQL module

    import MySQLdb

    connect

    db = MySQLdb.connect(host="localhost", db="test")

    create a cursor

    cursor = db.cursor()

    execute SQL statement

    cursor.execute("SELECT * FROM anmeldungen")

    get the resultset as a tuple

    result = cursor.fetchall()

    iterate through resultset

    for record in result:
    print record[0] , "-->", record[1]

    now the problem is that I can't connect cause there appears a dialog that asks me for the user/pass for my zope instance. When I enter the correct user/pass it says that this login data was wrong???

    Is there anybody who knows what this can be? Thanks for any help

     
    • Greg

      Greg - 2005-07-22

      I dont think you can do that from Pythonscript. You need to create ZSQL methods for connection from Zope. (with ZMySQLDA installed as well) Then from the Pythonscript you call your ZSQL methods, not MySQL directly. Try asking this on the Zope discussion list, someone with better knowledge might have better answer why.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.