R
Rene Pijlman
Andrew:
What does that mean?
In general, it's unwise to reconnect to a database server for every single
data manipulation. Keep the connection open, and perhaps even the cursor.
But I'm not sure if and how this works precisely with MySQL, I prefer
PostgreSQL myself.
Also, you seem to be forgetting the commit and disconnect.
^^^^^^^^^^^^^^^^and was wondering if anyone out there could help me optomize this code. [...]
self.db = MySQLdb.connect("localhost", "", "", "guestbook")
self.c = self.db.cursor()
self.c.execute("DELETE FROM guests WHERE id LIMIT 1;")
What does that mean?
self.results = self.c.fetchall()
In general, it's unwise to reconnect to a database server for every single
data manipulation. Keep the connection open, and perhaps even the cursor.
But I'm not sure if and how this works precisely with MySQL, I prefer
PostgreSQL myself.
Also, you seem to be forgetting the commit and disconnect.