[CONPY-194] executemany does not work with returning clause Created: 2022-02-19  Updated: 2022-07-07  Resolved: 2022-02-20

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.0.10
Fix Version/s: 1.0.11, 1.1.2

Type: Bug Priority: Major
Reporter: Luciano Barcaro Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Python Version: 3.9.9

 Description   

executemany accepts returning clause in query, but it does not return any resultset.

execute with many values, works as expected.

>>> import mariadb
>>> db = mariadb.connect(host='192.168.1.1', user='Administrador', password='xxxxxxx', database='yyyyyyy')
>>> qr = db.cursor(buffered=True)
>>> 
>>> qr.execute('create table temp_test (a int unsigned not null primary key auto_increment, b int)')
>>> rows = [(1, ), (2, ), (3, )]
>>> qr.executemany('insert into temp_test (b) values (?) returning a', rows)
>>> qr.fetchall()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
mariadb.ProgrammingError: Cursor doesn't have a result set
>>> 
>>> qr.execute('insert into temp_test (b) values (1), (2), (3) returning a')
>>> qr.fetchall()
[(4,), (5,), (6,)]
>>> 



 Comments   
Comment by Luciano Barcaro [ 2022-02-21 ]

Hi Georg,
thanks for your quick response.

I'll looking your code and I saw a slightly different implementation between 1.0 and 1.1 series.

1.0 the inner if is

if (MrdbCursor_InitResultSet(self))

And 1.1 is

if (!MrdbCursor_InitResultSet(self))

is this a typo error or the logic is inverted?

Comment by Georg Richter [ 2022-02-22 ]

Hi Luciano,

1.1 is different, major parts were rewritten and lot code was moved from C to Python - so this is correct.

Generated at Thu Feb 08 03:30:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.