What is the result of cursor.executemany()?

930 views
Skip to first unread message

Johannes Braunias

unread,
Jan 16, 2012, 5:10:16 PM1/16/12
to pymysq...@googlegroups.com
What is the result of cursor.executemany()?

The output of the attached file (creates a database scheme mydb with tables and should fill them) (reproducable) gives me 
values 0, 1, and 3 (or 4) for the following insert statements:
What is the meaning?
My problem is that only some of the insert statements get actually executed/committed.

print(cur.executemany("insert into mydb.number(tagname,name,shortform) values (%s, %s, %s)", [('ЕД','singular','sg'), ('МН','plural','p')] ))
print(cur.executemany("insert into mydb.person(tagname,name,shortform) values (%s, %s, %s)", [('1-Л','first','1st'), ('2-Л','second','2nd'), ('3-Л','third','3rd')] ))
print(cur.executemany("insert into mydb.pos(tagname,name,shortform) values (%s, %s, %s)", [('S','noun','s'), ('A','adjective','a'), ('ADV','adverb','adv'), ('NUM','numeral','num'), ('PR','preposition','pr'), ('COM','composite','com'), ('CONJ','conjunction','conj'), ('PART','particle','part'), ('P','word-clause','p'), ('INTJ','interjection','intj'), ('NID','foreign-named-entity','nid'), ('V','verb','v')] ))
print(cur.executemany("insert into mydb.prdform(tagname,name,shortform) values (%s, %s, %s)", [('КР','short','bre')] ))
print(cur.executemany("insert into mydb.tense(tagname,name,shortform) values (%s, %s, %s)", [('ПРОШ','past','pst'), ('НЕПРОШ','nonpast','npst'), ('НАСТ','present','pres')] ))
print(cur.executemany("insert into mydb.vform(tagname,name,shortform) values (%s, %s, %s)", [('ИНФ','infinitive','inf'), ('ПРИЧ','participle','pcp'), ('ДЕЕПР','gerund','grd')] ))
print(cur.executemany("insert into mydb.voice(tagname,name,shortform) values (%s, %s, %s)", [('СТРАД','passive','pass')] ))
print(cur.executemany("insert into mydb.animacy(tagname,name,shortform) values (%s, %s, %s)", [('ОД','animate','anim'), ('НЕОД','inanimate','inanim')] ))
print(cur.executemany("insert into mydb.aspect(tagname,name,shortform) values (%s, %s, %s)", [('НЕСОВ','imperfective','ipf'), ('СОВ','perfective','pf')] ))
print(cur.executemany("insert into mydb.case(tagname,name,shortform) values (%s, %s, %s)", [('ИМ','nominative','nom'), ('РОД','genitive','gen'), ('ПАРТ','partitive','part'), ('ДАТ','dative','dat'), ('ВИН','accusative','acc'), ('ТВОР','instrumental','ins'), ('ПР','prepositive','prp'), ('МЕСТН','locative','loc'), ('ЗВ','vocative','voc')] ))
print(cur.executemany("insert into mydb.degree(tagname,name,shortform) values (%s, %s, %s)", [('СРАВ','comparative','cmpr'), ('ПРЕВ','superlative','sprl')] ))
print(cur.executemany("insert into mydb.gender(tagname,name,shortform) values (%s, %s, %s)", [('МУЖ','masculine','m'), ('ЖЕН','feminine','f'), ('СРЕД','neuter','n')] ))
print(cur.executemany("insert into mydb.mood(tagname,name,shortform) values (%s, %s, %s)", [('ИЗЪЯВ','indicative','indic'), ('ПОВ','imperative','imper')] ))
print(cur.executemany("insert into mydb.blank(tagname,name,shortform) values (%s, %s, %s)", [('_','',''), ('meta','',''), ('mild','',''), ('non-standard','',''), ('incorrecdt','',''), ('compound','','')] ))
conn.commit()

exit()




D:\Sources\Russian Code\scripts\verbs>processverbphrases2sql.py
1
0
0
0
0
0
0
0
0
0
0
0
0
4

Only some of the tables are filled :-(
insert_fail.py

Johannes Braunias

unread,
Jan 16, 2012, 5:17:21 PM1/16/12
to pymysq...@googlegroups.com
Sorry for so much posting … I looked the code up now on https://github.com/petehunt/PyMySQL/blob/master/pymysql/cursors.py
I understand that a number > 0 means the number of rows inserted.
But how can I get the result of the action (success or failure, and in case of failure, an error message)?
Reply all
Reply to author
Forward
0 new messages