lastError() returns:

Qt Code:
  1. attempt to write a readonly database Unable to fetch row
To copy to clipboard, switch view to plain text mode 

but in command line everything works fine.