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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.