knadh / tg-archive

A tool for exporting Telegram group chats into static websites like mailing list archives.
MIT License
834 stars 124 forks source link

Error: duplicate column name: takeout_id #75

Closed icepaule closed 2 years ago

icepaule commented 2 years ago

Hello, could someone please help me with his issue. Doing a fresh install but getting below error:

Thanks so much for your help and the great tool. Marcus

root@xxx# tg-archive --sync 2022-07-20 18:29:51,555: cryptg detected, it will be used for encryption 2022-07-20 18:29:51,952: starting Telegram sync (batch_size=2000, limit=100, wait=5, mode=standard) Traceback (most recent call last): File "/usr/local/bin/tg-archive", line 33, in sys.exit(load_entry_point('tg-archive==0.5.5', 'console_scripts', 'tg-archive')()) File "/usr/local/lib/python3.10/dist-packages/tg_archive-0.5.5-py3.10.egg/tgarchive/init.py", line 140, in main s = Sync(cfg, args.session, DB(args.data)) File "/usr/local/lib/python3.10/dist-packages/tg_archive-0.5.5-py3.10.egg/tgarchive/sync.py", line 29, in init self.client = self.new_client(session_file, config) File "/usr/local/lib/python3.10/dist-packages/tg_archive-0.5.5-py3.10.egg/tgarchive/sync.py", line 102, in new_client client = TelegramClient(session, config["api_id"], config["api_hash"]) File "/usr/local/lib/python3.10/dist-packages/Telethon-1.24.0-py3.10.egg/telethon/client/telegrambaseclient.py", line 273, in init session = SQLiteSession(session) File "/usr/local/lib/python3.10/dist-packages/Telethon-1.24.0-py3.10.egg/telethon/sessions/sqlite.py", line 55, in init self._upgrade_database(old=version) File "/usr/local/lib/python3.10/dist-packages/Telethon-1.24.0-py3.10.egg/telethon/sessions/sqlite.py", line 147, in _upgrade_database c.execute("alter table sessions add column takeout_id integer") sqlite3.OperationalError: duplicate column name: takeout_id

knadh commented 2 years ago

hm, this looks like a bug in the Telethon library, something to do with the takeout mode. Can you try setting use_takeout to False in the config file?

icepaule commented 2 years ago

Doesn't change the result. - Same error.

icepaule commented 2 years ago

Following your suggestion, I've reinstalled telethon itself from git.

Now, the error changes:

tg-archive --sync --config ./config.yaml 2022-07-21 07:46:42,395: cryptg detected, it will be used for encryption Traceback (most recent call last): File "/usr/local/bin/tg-archive", line 33, in sys.exit(load_entry_point('tg-archive==0.5.5', 'console_scripts', 'tg-archive')()) File "/usr/local/lib/python3.10/dist-packages/tg_archive-0.5.5-py3.10.egg/tgarchive/init.py", line 127, in main from .sync import Sync File "/usr/local/lib/python3.10/dist-packages/tg_archive-0.5.5-py3.10.egg/tgarchive/sync.py", line 11, in from telethon import TelegramClient, errors, sync ImportError: cannot import name 'sync' from 'telethon' (/usr/local/lib/python3.10/dist-packages/Telethon-1.24.0-py3.10.egg/telethon/init.py)

So, I'm digging deeper for the "sync" module. :-)

knadh commented 2 years ago

When you reinstalled, did you delete data.sqlite and the session file too? If not, should delete both and retry with takeout disabled.