Skip navigation links

MySQL Forums :: Connector/Python :: executemany statement with a subquery


Advanced Search

executemany statement with a subquery
Posted by: Robert Koziol ()
Date: October 06, 2012 10:28AM

Hi all,

I have to insert many rows into DB with some nested select subquery.

I tried something like that:

eventsFlat = []
eventsFlat.append((event.id1, event.id2, event.league, event.date, event.type, event.subtype, event.period))
...
self.__cursor.executemany(
"""INSERT INTO events (mainevent_id, eventtype_id, eventsubtype_id, period_id) VALUES
((select id from mainevents where first_competitor_id=%s and second_competitor_id=%s and league_id=%s and event_date=%s), %s, %s, %s)""",
eventsFlat)

All I got is the error:

TypeError('not all arguments converted during string formatting',)

Is this possible to use executemany to insert rows but with some select subquery included in?

Kind regards,
Rob



Edited 1 time(s). Last edit at 10/06/2012 11:36AM by Robert Koziol.

Options: ReplyQuote


Subject Written By Posted
executemany statement with a subquery Robert Koziol 10/06/2012 10:28AM
Re: executemany statement with a subquery Andrii Nikitin 10/22/2012 07:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.