get row count from query method
Hi.
is it possible to get number of rows affected (in case of delete, update, insert, etc.) from query method?
not to my knowledge
I've also wanted this info; perhaps alongside .query there could be .execute which instead of returning a RecordCollection, returns the underlying ResultProxy from sqlalchemy?
The correct answer might be to go 'around' records a bit:
mydb = records.Database(...)
result = mydb.db.execute("delete from mytable where mycondition = 1")
Personally, I did a bit of monkeypatching to expose a .execute that matched query semantics a bit closer:
import records
from sqlalchemy import text
def rdb_execute(self, query, **params):
return self.db.execute(text(query), **params)
records.Database.execute = rdb_execute
Exposing the generic execute is also what #103 does, but he calls it in_bulk, which is a bit inaccurate. I agree with the implementation, but think it should be named execute.