Closed wirmi closed 3 years ago
Hi @wirmi, thanks for your contribution.
Unfortunately, your change would not work for me. In my database, display_name
only contains data when the "contact" is a group. For all other contacts the field is empty, but wa_name
contains the correct data.
Does display_name
also contain the names of your contacts? Is wa_name
empty for you?
Hi @chrrel!
It may be different in Spain or something, but wa_name
in my db is empty in almost cases (even a group), and the only column that shows everything is display_name
.
Anyways, can I use your code to mix with an app I'm doing?
Okay, thanks for the info. I'll try to check this with a second database, maybe something was changed within WhatsApp since I exported my data.
Yes! Feel free to use the code base for your project. It is all open source (license).
Thanks Christian, you can contact me if you need something 👍
I close the pull
My suggestion would be:
def query_contacts(db_path: str) -> Dict[str, Optional[str]]:
contacts = {}
con = sqlite3.connect(db_path)
cur = con.cursor()
for jid, wa_name, display_name in cur.execute("SELECT jid, wa_name, display_name from wa_contacts"):
if display_name:
contacts[jid] = display_name
elif wa_name:
contacts[jid] = wa_name
con.close()
return contacts
Using this approach we would consider both display_name
and wa_name
. Would this work for you, @wirmi?
I am going to push the proposed solution in a new commit as I do not have permission for modifying the merge request.
display_name is the name that you see in your device when using WhatsApp :)