I try to use this method, but it's also not a good idea:

    for x in range(1, 10901):
        person = session.query(Person).get(x)
        price = Price(int(array_name[x-1]), extra=0)
        session.add(price)
        session.flush()
        person.price_id = price.id
        session.add(person)
    session.commit()

This method is slower than the first method



W dniu niedziela, 30 czerwca 2013 12:46:43 UTC+2 użytkownik MacVictor 
napisał:
>
> array_name contains 10900 price.
>
> create_price = []
> for x in range(0, 10900):
>     price = Price(int(array_name[x]), extra=0)
>     create_price.append(price)
> session.add_all(create_price)
>
> for y in range(1, 10901):
>     session.query(Person).filter_by(id=y).update({"price_id": 
> session.query(Price).get(y).id},
>                                                  synchronize_session=False)
>     session.commit()
>
> But this is very slow.. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to