WhatsApp-Chat-Exporter: No such table: messages (Edit: Support for WhatsApp databases with "message" table)
When running the script I get following error message
Gathering contacts...(97)
Traceback (most recent call last):
File "C:\Users\******\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\******\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\******\AppData\Local\Programs\Python\Python310\Scripts\wtsexporter.exe\__main__.py", line 7, in <module>
File "C:\Users\******\AppData\Local\Programs\Python\Python310\lib\site-packages\Whatsapp_Chat_Exporter\__main__.py", line 147, in main
messages(db, data)
File "C:\Users\******\AppData\Local\Programs\Python\Python310\lib\site-packages\Whatsapp_Chat_Exporter\extract.py", line 88, in messages
c.execute("""SELECT count() FROM messages""")
sqlite3.OperationalError: no such table: messages
My database doesn’t contain the table messages, I only have one called message which contains the data but the schema of the table looks different from what it’s supposed to look like.
What could be the issue here?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 74 (37 by maintainers)
Commits related to this issue
- Support new WhatsApp database schema https://github.com/KnugiHK/Whatsapp-Chat-Exporter/issues/9 — committed to KnugiHK/WhatsApp-Chat-Exporter by KnugiHK 2 years ago
- Bug fix for sender name in group chat #9 — committed to KnugiHK/WhatsApp-Chat-Exporter by KnugiHK a year ago
- Handle deleted message in new schema Related to #39 and #9 — committed to KnugiHK/WhatsApp-Chat-Exporter by KnugiHK a year ago
- Support new WhatsApp database schema https://github.com/KnugiHK/Whatsapp-Chat-Exporter/issues/9 — committed to Goblincomet/WhatsApp-Chat-Exporter by Goblincomet 2 years ago
It should be fixed in the latest commit: https://github.com/KnugiHK/Whatsapp-Chat-Exporter/commit/d3892a4e4f4f0b533107f871a23de22153cc879a.
I can produce the same result on 2.22.7.73 and “messages” table no longer exist.
@Takepy As I can reproduce your situation now, I will work on supporting “message” table.
I created a new branch called “message_table” which support
messagetable directly from wtsexporter command. Feel free to give it a try but please expect bugs from the branch. Bug reports are welcome and should be reported in this issue.Also, big thank for the SQL statement written by @ulno. For the replacement of
key_remote_jid, sincesender_jid_row_idcould be 0, instead of treating it as thekey_remote_jid, I joined thechatandjidtable together to obtain the accuratekey_remote_jid.“messages” is the legacy one, please read https://thebinaryhick.blog/2022/06/09/new-msgstore-who-dis-a-look-at-an-updated-whatsapp-on-android/
Metadata is also treated as messages in the database. But since it is not the main focus when it comes to exporting chats, metadata may show as “not supported” unless handled like changes of the group name. Therefore, I will consider it not a bug if the chat is complete.
I will start preparing for the release when more tests are being performed.
No problem!
I think so. I would like to add support for older version. However, I don’t have such database, hence, I am not able to do it. If you have time and you want the script to work with your database, you can take a look inside the database and fine tune the script. Anyway, I will keep my eyes on the opportunity for supporting old databases. Thanks for your report!
vCards will be exported to ./WhatsApp/vCards and copied to the output directory by default. If you don’t want two identical folders, try -c (–move-media) flag.
Hello everyone! We are finally moving to the last step before releasing this update.
I merged the logic for processing old and new schema in
extract.pyin commit fb88124. As it is not a commit specifically for themessagetable, it will not be merged into themessage_tablebranch, and the branch will not be updated from now on. And changes will be committed to thedevbranch as usual.Feel free to try it, especially for those with databases with both
messageandmessagestables, to see if there is any compatibility issue.I had to cherry-pick the fix for https://github.com/KnugiHK/Whatsapp-Chat-Exporter/issues/32 and then it worked perfectly. Thank you for making this tool!
I checked out the message_table branch and used it to extract my newer ‘message’ DB successfully. All conversations including group conversations were converted to HTML. Many thanks @KnugiHK !
The new branch worked on my side – thanks a lot ! Although all medias are missing from the htmls (i tried both with and without the -e flag). Thanks a lot for your work, your tool is great.
I will have a look at the clash later.
I played with it a bit yesterday and replaced the main query in extract.py with this:
That brings me past the missing messages table, but will clash in extract.py:240 trying to match the remote id to something in the big data dictionary. So, I assume me trying to replace key_remote_jid with sender_jid_row_id might go into the right direction, but might need some more joints to actually turn things into a phone number.
There are also a messages_view and a chats_view now that seem to match some more tables with each other. Did anybody else figure some dependencies based on their connections out?
I’m not certain, using the outdated WhatsApp version both tables exist, in the more recent version (downloaded from whatsapp.com yesterday) only the
messagetable existed.Edit: Just checked, in my current setup (outdated version) messages are only stored in the
messagestable (which works awesome with your script!) and themessagetable appears to be empty.I’ll give it a try later and report back.