Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

executemany statement with a subquery (no replies)

$
0
0
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

Viewing all articles
Browse latest Browse all 384

Trending Articles