Tejaswini Jadhav
Tejaswini Jadhav

Reputation: 13

How can check if data is inserted or not in crate db using python?

I am trying to insert data in crate DB using the crate client python package. I am not able to check if data is inserted in crate db or not? if one record is inserted in one table and another record has not been inserted into another table. How can I rollback first table data in crate DB

Upvotes: 0

Views: 151

Answers (1)

mict0
mict0

Reputation: 43

Are you having problem with making sure that data is inserted in db or something else?

You can do something like this:

result = cursor.executemany(query:str, items:list)

and result will be the list of dicts for every item you've tried to insert

[{'rowcount': 1}, {'rowcount': 1}]

if something went wrong rowcount would be -2 and you'll get error message. Otherwise you can just query the db and see if that item is inserted previously.

Upvotes: 1

Related Questions