carderne / signal-export

Export your Signal chats to markdown files with attachments
Other
446 stars 47 forks source link

pysqlcipher3.dbapi2.DatabaseError: malformed database schema (messages_on_view_once_update) - no such table: main.messages #23

Closed franklin-be closed 3 years ago

franklin-be commented 3 years ago

Hello,

thank your very much for your efforts in giving us an option to export or signal history. I've set this up via WSLv2 on Windows and after a lot of struggling i eventually got it work by following your linux instructions and googling every other problem i came along the way.

After doing my first successful export a couple of days ago... i strugle to do another however D: I tried with several different dbs (from different systems to make sure it's not a faulty database) but i always end up getting

root@user0pc:/home/user0# python3 /signal-export/sigexport.py --source "/mnt/c/temp/trans/Signal/" --manual "/home/user0/Desktop/" --verbose

Fetching data from /mnt/c/temp/trans/Signal/sql/db.sqlite

ok

Traceback (most recent call last): File "/signal-export/sigexport.py", line 617, in main() File "/usr/lib/python3/dist-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke return callback(args, **kwargs) File "/signal-export/sigexport.py", line 581, in main convos, contacts = fetch_data(db_file, key, manual=manual, chats=chats) File "/signal-export/sigexport.py", line 213, in fetch_data c.execute(query) pysqlcipher3.dbapi2.DatabaseError: malformed database schema (messages_on_view_once_update) - no such table: main.messages

any pointers what to look at?

my phyton version:

root@user0pc:/home/user0# python3 -c 'import sys;print(f"{sys.version}")' 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]

regards

Franklin

carderne commented 3 years ago

Hi @franklin-be, congrats on getting it to work even once!

If you run with --manual, the script attempts to decrypt the database into a separate file and then runs the queries against that.

First thing I'd try: find the sqlite file db-decrypt.sqlite in the same directory as the original Signal sqlite file. Then try opening that with some graphical browser (try Googling windows sqlite browser or something) or using the command line if you're comfortable. Then have a look inside and see if has the tables it should!

The script expects a table conversations with the following columns: https://github.com/carderne/signal-export/blob/1d0ffb513744ef7dda228f2d6927fd0abfdbedfb/sigexport.py#L209

And another table messages with the following columns: https://github.com/carderne/signal-export/blob/1d0ffb513744ef7dda228f2d6927fd0abfdbedfb/sigexport.py#L246

franklin-be commented 3 years ago

They all seem to be where they are and the select statements execute fine as well.

Tables

Select

carderne commented 3 years ago

Please try making the following change to sigexport.py:

diff --git a/sigexport.py b/sigexport.py
index 0a173eb..9716dac 100755
--- a/sigexport.py
+++ b/sigexport.py
@@ -9,7 +9,7 @@ from datetime import datetime
 import re

 import click
-from pysqlcipher3 import dbapi2 as sqlcipher
+import sqlite3 as sqlcipher
 import markdown
 from bs4 import BeautifulSoup

Basically just replace the line from pysqlcipher3 import dbapi2 as sqlcipher with import sqlite3 as sqlcipher.

And let me know if it works!

franklin-be commented 3 years ago

worked like a charm! Thank you so much for your help!

carderne commented 3 years ago

This is fixed now in 3419c3b.

carderne commented 3 years ago

@franklin-be if you have any tips for getting it to work on Windows other than "use WSL" please share.