Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planning to add support to sqlalchemy 1.4? #5

Open
SantiMNV opened this issue Sep 6, 2023 · 2 comments
Open

Planning to add support to sqlalchemy 1.4? #5

SantiMNV opened this issue Sep 6, 2023 · 2 comments

Comments

@SantiMNV
Copy link

SantiMNV commented Sep 6, 2023

Hi, I am developing a project in FastAPI and wishing to use turso.
FastAPI works mainly with sqlmodel, a mix between pydantic and sqlalchemy.
It does not support sqlalchemy 2.0 so far.

How to implement this project to use FastAPI?
Is there a plan of migrating this to previous sqlalchemy versions?

Thanks!

@barbieri
Copy link
Collaborator

barbieri commented Sep 6, 2023

hi @SantiMNV we can look into porting it to older versions, will check about the priorities and when we could do it.

But if you're willing to do that, the code should be pretty simple: https://github.com/libsql/sqlalchemy-libsql/blob/main/sqlalchemy_libsql/__init__.py#L85

See we build on top of the sqlite3 dialect, since our Python API is compatible with dbapi2 (import sqlite3.dbapi2 can be replaced with import libsql_client.dbapi2), then we expose that in https://github.com/libsql/sqlalchemy-libsql/blob/main/sqlalchemy_libsql/__init__.py#L91, with connect() being rewritten to not restrict the URL to be only files https://github.com/libsql/sqlalchemy-libsql/blob/main/sqlalchemy_libsql/__init__.py#L109 (compare to https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/dialects/sqlite/pysqlite.py#L578-L586)

@Blastorios
Copy link

Note: They have been making great progress in fastapi/sqlmodel#632 to make SQLModel work with SQLAlchemy 2.0.

Although backporting might still be an interesting use case (as I am sure there will be other packages relying on an older version of alchemy), this specific use case will most likely be solved in a short timeframe.

You can already use a temporary fork https://github.com/mbsantiago/sqlmodel if you are on a deadline (they have already been testing quite extensively).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants