Telethon: OperationalError: database is locked

后端 未结 3 1672
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-16 18:13

Apologies if it is a silly question.

I am trying telethon for the first time and it fails to synchronize with my telegram API.

I get an IP address when I ty

3条回答
  •  终归单人心
    2021-01-16 18:23

    To solve the infamous

    OperationalError: database is locked

    error caused by sqllite3, one solution is to find the .session file created the first time you ran the code and delete it. Telethon puts those files in the same folder as your Python code or Jupyter Notebook. Or alternatively, you could use Python to get rid of the file automatically:

    import os
    import sys
    os.chdir(sys.path[0])
    
    if f"{SESSION_NAME}.session" in os.listdir():
        os.remove(f"{SESSION_NAME}.session")
    

    assuming you are using the SESSION_NAME string variable to store the session name parameter of the TelegramClient() function.

提交回复
热议问题