will bulk insertion of data is auto committed for each row insertion ????

13 views
Skip to first unread message

kampy

unread,
Sep 20, 2012, 7:19:50 AM9/20/12
to sqlal...@googlegroups.com
Hi all ,

I am trying bulk data into mysql database through sqlalchemy. In the table there may be primary key values before. If we get the same primary key values we get Integrity Error so I am using transaction management here. But while inserting bulk data the rows inserted before this error werent get rolled back only the row where error is got is rolled back. Can anyone please help me out in gettin gout this issue.

Thanks in advance

Michael Bayer

unread,
Sep 20, 2012, 9:36:21 AM9/20/12
to sqlal...@googlegroups.com
sounds like you aren't using InnoDB and therefore there's really no transaction in place at all.  The (often default) MyISAM engine of MySQL doesn't support transactions.


--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/mxq1e7yJoOQJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

kampy

unread,
Sep 20, 2012, 10:20:47 AM9/20/12
to sqlal...@googlegroups.com
HI Michael Bayer,
I am using InnoDB only.

users_table = Table(XXXXXX',metadata,
    Column('id1, Integer, primary_key=True,
                         autoincrement=False),
    Column('id2', String(255), primary_key=True),
    Column('d3', String(255), primary_key=True),
    Column('t_id',String(255)),
    Column('ie_name',String(255)),
    Column('n_name',String(255)),
    Column('in_status',String(255)),
    Column('ud_at',DateTime),
    Column('c_at',DateTime),
    Column('d_at',DateTime),
    mysql_engine='InnoDB'
)

Michael Bayer

unread,
Sep 20, 2012, 10:29:57 AM9/20/12
to sqlal...@googlegroups.com
if rows that were inserted in the transaction are not removed when the transaction rolls back, then that's the only possibility here.   are you sure you emitted a CREATE TABLE statement for the "users_table" definition which included InnoDB ?


To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/6vP2FZqsZEYJ.

kampy

unread,
Sep 20, 2012, 10:40:42 AM9/20/12
to sqlal...@googlegroups.com
i created table manually  not in the code .

Michael Bayer

unread,
Sep 20, 2012, 10:44:41 AM9/20/12
to sqlal...@googlegroups.com
this would need to include "engine='InnoDB'" in the CREATE TABLE statement.


To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/PCyh3Gh31MwJ.
Reply all
Reply to author
Forward
0 new messages