tursodatabase / libsql-client-py

Python SDK for libSQL
https://libsql.org/libsql-client-py/
MIT License
44 stars 10 forks source link

fix: rename sqlite3.py to sqlite3_utils.py and correct imports - avoi… #25

Closed Abdur-rahmaanJ closed 5 months ago

Abdur-rahmaanJ commented 5 months ago

…d runtime errors

penberg commented 5 months ago

@Abdur-rahmaanJ What is the error you are seeing?

Abdur-rahmaanJ commented 5 months ago

Sorry, filling up

Problem

I began experiencing sqlite errors on 3 python hosts,

  1. Render.com
    dbapi = dbapi_meth(**dbapi_args)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/sqlalchemy_libsql/__init__.py", line 92, in import_dbapi
    from libsql_client import dbapi2 as libsql_client
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/libsql_client/dbapi2/__init__.py", line 16, in <module>
    from ._reexports import *  # noqa: F401,F403
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/render/project/src/.venv/lib/python3.11/site-packages/libsql_client/dbapi2/_reexports.py", line 76, in <module>
    from sqlite3.dbapi2 import (
ImportError: cannot import name 'SQLITE_BUSY_TIMEOUT' from 'sqlite3.dbapi2' (/usr/local/lib/python3.11/sqlite3/dbapi2.py)
  1. koyeb.com, Python3.12

Selection_330

  1. pythonanywhere.com, Python3.10

Selection_331

The app runs fine on my PC, mint 20 with Python3.11, and Python3.12 though. It just gives errors on deploys.

Solution background

While searching for an answer i saw this SO post about AttributeNotFound for SQLite, with the issue being a file named sqlite3.py present in the target project.

Iit's never a good idea, irrespective of my issue to name a file the same as a module or package, happens often when people name their first Flask app, flask.py.

The project i was trying to deploy is this one: https://github.com/linkversity/linkversity

I contacted Render's support, they are as clueless as me.

So, @penberg hope it helps!

How this PR helps

It renames sqlite3.py to sqlite3_utils and renames imports accordingly.

Abdur-rahmaanJ commented 5 months ago

@penberg You have an idea when this fix will be deployed?

penberg commented 5 months ago

@Abdur-rahmaanJ I just released 0.3.1 with this fix.