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

new 0.8 version for sqlite connection with '?mode=ro' not working, Error can't open database #585

Open
Pythonbeginer2014 opened this issue Mar 1, 2024 · 1 comment

Comments

@Pythonbeginer2014
Copy link

Pythonbeginer2014 commented Mar 1, 2024

from contextlib import asynccontextmanager
from databases import Database


@asynccontextmanager
async def async_sqlite_conn(db_name):
    database = Database(f'sqlite+aiosqlite:///example.db?mode=ro', uri=True)
    try:
        await database.connect()
        yield database
    finally:
        await database.disconnect()

when call this function and query data, get error " can't open database"

Thanks ,

@Sebcio03
Copy link

Hi @Pythonbeginer2014,

I tried to reproduce your problem using python 3.12 with databases 0.8 and for me it works perfectly:
image

Try again but make sure you have write/read access to directory where you want to create file with database, remove file (it might be somehow corrupted)

If still this won't work can you please show us your exception logs, and pip freeze

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

2 participants