0

Currently i'm using Alchemy as a ORM, and I look for a way to speed up my insert operation, I have bundle of XML files to import

for name in names:
    p=Product()
    p.name="xxx"
    session.commit()

i use above code to insert my data paser from batch xml file to mysql,it's very slow also i tried to

for name in names:
    p=Product()
    p.name="xxx"
session.commit()

but it seems didn't change anything

1
  • @mizboy you would need to provide more info. Just not enough info to suggest speed optimization. Provide current queries etc. Commented Oct 6, 2010 at 16:28

1 Answer 1

1

You could bypass the ORM for the insertion operation and use the SQL Expression generator instead.

Something like:

conn.execute(Product.insert(), [dict(name=name) for name in names])

That should create a single statement to do your inserting.

That example was taken from lower down the same page.

(I'd be interested to know what speedup you got from that)

Sign up to request clarification or add additional context in comments.

1 Comment

finally i use mysqlimport cmd tool instead,it's really quick,but should build a csv file

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.