Skip to content

Commit

Permalink
fix: sqlite3.ProgrammingError
Browse files Browse the repository at this point in the history
Recursive use of cursors not allowed.
  • Loading branch information
AbhiTheModder committed Aug 8, 2024
1 parent 8de13ea commit 46a2d50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions modules/upl.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ async def upl(client: Client, message: Message):
await message.edit(format_exc(e))


@Client.on_message(filters.command("dlf", prefix) & filters.me)
async def dlf(client: Client, message: Message):
if message.reply_to_message.document:
await client.download_media(message.reply_to_message)


@Client.on_message(filters.command("moonlogs", prefix) & filters.me)
async def mupl(client: Client, message: Message):
link = "moonlogs.txt"
Expand Down
8 changes: 5 additions & 3 deletions utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def _execute(self, module: str, *args, **kwargs) -> sqlite3.Cursor:

self._lock.acquire()
try:
return self._cursor.execute(*args, **kwargs)
cursor = self._conn.cursor()
return cursor.execute(*args, **kwargs)
except sqlite3.OperationalError as e:
if str(e).startswith("no such table"):
sql = f"""
Expand All @@ -139,9 +140,10 @@ def _execute(self, module: str, *args, **kwargs) -> sqlite3.Cursor:
type TEXT NOT NULL
)
"""
self._cursor.execute(sql)
cursor = self._conn.cursor()
cursor.execute(sql)
self._conn.commit()
return self._cursor.execute(*args, **kwargs)
return cursor.execute(*args, **kwargs)
raise e from None
finally:
self._lock.release()
Expand Down

0 comments on commit 46a2d50

Please sign in to comment.