databases icon indicating copy to clipboard operation
databases copied to clipboard

Async database support for Python. 🗄

Results 140 databases issues
Sort by recently updated
recently updated
newest added

I wasn't able to find a way to properly use the transaction decorator when using with other decorators in the docs. I thought it would be helpful to add this...

SQLAlchemy escapes the bind variable names and when it does so, the query execution fails with encode/databases. The linked issue [Here](https://github.com/sqlalchemy/sqlalchemy/issues/8112). The workaround is to use `literal` instead of `bindparam`.

code ``` # Create a database instance, and connect to it. import asyncio import contextvars from urllib.parse import quote from databases import Database database = Database(f'mysql://root:{quote("123456")}@192.168.1.80/learn_db') async def main(): await...

``` async with database.transaction() as transaction: query = insert(Session).values({"foo": "bar"}) last_insert_id = await database.execute(query) (uid, ) = await database.fetch_one("SELECT LAST_INSERT_ID() as id") assert uid == last_inserted_id # True ``` It...

Below is my code ```python async with conn.transaction(force_rollback=True): transaction = await conn.transaction() try: query = user.insert().values(**row["data"]) await conn.execute(query=query) query_sms = ( user_sms.update() .where(user_sms.c.ccode == "code") .values(status=1) ) await conn.execute(query=query_sms) except...

When there are multiple queries executed in fastapi endpoint handler, the transaction rollback doesn't work properly. ``` @app.post("/notes/") async def create_note(note: NoteIn): # WHEN We execute some query outside transaction...

bug

Hi all, we've been experiencing some issues with Databases regarding connection and transaction management, so I've spent some time reading through the different issues and PRs and understanding the code....

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account. -...

This code: ```python import asyncio from databases import Database async def amain(): db = Database( # a url ) await db.connect() query = """ SELECT * FROM things WHERE things.id...

something like this ```python async for rows in database.iterate(query, values, n=10): rows ``` where `rows` would have 10 rows until there is

feature