Code

Opened 5 years ago

Closed 5 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: UI/UX:

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))" )

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by kayu

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 5 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.