dbcli / litecli

CLI for SQLite Databases with auto-completion and syntax highlighting
https://litecli.com
BSD 3-Clause "New" or "Revised" License
2.47k stars 73 forks source link

Affected rows is -1 #1

Closed amjith closed 6 years ago

amjith commented 6 years ago

Create table results displays -1 as affected rows.

sqlite3 amjith::memory:> create table foo (id integer, name varchar);
Query OK, -1 rows affected
delgermurun commented 6 years ago

@amjith How about replacing -1 with 0 :) ?

drop table foo returns -1 too. mycli returns 0 on both queries.

amjith commented 6 years ago

Replacing it with zero sounds fine. I just want to understand why it returns -1. Is that a latent bug in our code or is the sqlite connector behaving badly?

delgermurun commented 6 years ago

Not our code's bug. sqlite3 library returns rowcount=-1 and cursor.fetchall() returns [] empty list.

amjith commented 6 years ago

If the rowcount is unreliable from the sqlite3 library let's not use it at all. We'll just rely on our own counting to report that number.

delgermurun commented 6 years ago

Okay. Got it.

delgermurun commented 6 years ago

insert, delete queries return correct row count while cursor.fetchall() returns []. So we need to use rowcount for those case, I think.

delgermurun commented 6 years ago

@amjith I pushed little fix.

amjith commented 6 years ago

Works great!