Opened 10 years ago

Closed 10 years ago

#10198 closed (invalid)

Can't execute 'INSERT' in MYSQL normally

Reported by: kayu Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The following code can be run and no error indicate, but no data insert into MySql table
cursor = connection.cursor()
cursor.execute("insert into foo (data) value ('abc')")

But when I run with 'CREATE' command, the data will insert into the table normally. Following is a example,
cursor = connection.cursor()
cursor.execute("insert into foo (data) value ('abc')")
cursor = connection.cursor()
cursor.execute("CREATE TABLE foo2 ( id int(11))" )

Change History (2)

comment:1 Changed 10 years ago by kayu

The following code can be run and no error indicate, but no data insert into MYSQL table
cursor = connection.cursor()
cursor.execute("insert into foo (data) value ('abc')")

But when I run with 'CREATE' command, the data will insert into the table normally. Following is a example,
cursor = connection.cursor()
cursor.execute("insert into foo (data) value ('abc')")
cursor = connection.cursor()
cursor.execute("CREATE TABLE foo2 ( id int(11))" )

comment:2 Changed 10 years ago by Malcolm Tredinnick

Resolution: invalid
Status: newclosed

I'm not seeing the Django bug here.

How are you testing that nothing is inserted into the database? By making sure you either close the connection or commit the transaction first (since connections aren't in auto-commit mode, by default)? Repeating the same test you provide works for me.

I think it's fairly safe to say that MySQL inserting works correctly, since, for example, the testsuite for Django passes and does a few thousand inserts in the process. There's something special about the way you're using the connection and/or checking for the results. If you really can't work this out, perhaps provide some details on the django-users mailing list and somebody might be able to provide some ideas (ensure you include information such as versions and operating system).

Closing for now, though, since this doesn't look like a Django bug.

Note: See TracTickets for help on using tickets.
Back to Top