Sorry for the noob question.  Why do I only end up with 2 inserted
rows when doing this?

>>> from sqlalchemy import *
>>> db = create_engine('mysql://login:[EMAIL PROTECTED]/database')
>>> metadata = BoundMetaData(db)
>>> temptable = Table('temptable', metadata,
... Column('col1', Integer),
... Column('col2', String(10)))
>>> temptable.create()
>>> data = [(1, 'blah1'), (2, 'blah2'), (2, 'blah2'), (3, 'blah3'), (3, 
>>> 'blah3'), (3, 'blah3')]
>>> temptable.insert(values=data).execute()
<sqlalchemy.engine.base.ResultProxy object at 0x01169C70>
>>> s = temptable.select()
>>> e = s.execute()
>>> e.fetchall()
[(1L, 'blah1'), (2L, 'blah2')]

But if I continue in another table and insert via a loop, it works
fine:

>>> temptable2 = Table('temptable2', metadata,
... Column('col1', Integer),
... Column('col2', String(10)))
>>> temptable2.create()
>>> for i in data:
...     temptable2.insert(values=i).execute()
...
<sqlalchemy.engine.base.ResultProxy object at 0x011745B0>
<sqlalchemy.engine.base.ResultProxy object at 0x011747D0>
<sqlalchemy.engine.base.ResultProxy object at 0x01174910>
<sqlalchemy.engine.base.ResultProxy object at 0x01174A50>
<sqlalchemy.engine.base.ResultProxy object at 0x01174B90>
<sqlalchemy.engine.base.ResultProxy object at 0x01174CD0>
>>>

Is there some better way to do bulk inserts that I am missing?

Thanks in advance


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to