2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
895 stars 79 forks source link

how can i know the number of update rows #126

Open skyatgit opened 1 year ago

skyatgit commented 1 year ago

db.query_result don't show the number of update rows

2shady4u commented 1 year ago

Hi @skyatgit

At the moment there's no way to get the number of changes. I'll see about implementing it in the next version.

skyatgit commented 1 year ago

ok,thanks

2shady4u commented 1 year ago

Hello @skyatgit

Good news 😄 You can already get the number of changes in the current version of the library by using following query:

db.query("SELECT CHANGES();")
print(db.query_result)

Which will then output the following in the Godot console:

[{CHANGES():0}]

With 0 being replaced with whatever number changes were done in the previous query.

I'll see if there's any merit to implementing some additional wrappers around the sqlite3_total_changes and sqlite3_changes-methods, but I assume that the query above already fixes your issue 😄

skyatgit commented 1 year ago

@2shady4u ok,thank you~ and i think in the next version if the query is not 'select',the query_result return the changes count is a good thing,of course, it depends on your decision

feefladder commented 1 year ago

maybe the return value for update_rows could be made to reflect that? e.g. -1 for error and 0,1... for success? Not sure if really necessary though, but would be nice (breaks compatibility)