My code:

from MySQLdb import *
sql_q = '("6 bandicoot crescent doolandella brisbane qld","inala","3","7"),("inala brisbane","forest lake brisbane","3","9")'
connection = connect(host = 'localhost', user = 'python', passwd = '******', port = 3306, db = 'logbook')
cursor = connection.cursor()
cursor.execute('INSERT INTO log VALUES' + sql_q)
cursor.commit()

I seem to get this error:

Traceback (most recent call last):
  File "C:/Users/Salman/Desktop/logbook/test.py", line 18, in <module>
    cursor.commit()
AttributeError: 'Cursor' object has no attribute 'commit'

I can't seem to work out why..I know I've used commit before in Python 2.5

Commit is a method on the connection object.
Try connection.commit()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.