Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Simple query that works with sqlalchemy fails with databases #128

@trvrmcs

Description

@trvrmcs

A simple COUNT(*) works using sqlalchemy.Engine.execute(), but fails using databases.Database.fetch_all(), raising an IndeterminateDatatypeError exception.

import asyncio
import databases
import sqlalchemy
from sqlalchemy import Column, MetaData, Text, Table, select, func


url = "postgresql://test:password@localhost/example"
engine = sqlalchemy.create_engine(url)


metadata = MetaData()
People = Table("people", metadata, Column("name", Text()))
QUERY = select([func.count("*")]).select_from(People)


def setup():
    engine.execute("CREATE TABLE IF NOT EXISTS people(name text)")


def test_sync():
    "this works"
    engine.execute(QUERY).fetchall()


async def test_async():
    "this fails with 'asyncpg.exceptions.IndeterminateDatatypeError: could not determine data type of parameter $1'"
    database = databases.Database(url)
    await database.connect()
    await database.fetch_all(QUERY)
    await database.disconnect()


if __name__ == "__main__":
    setup()
    test_sync()

    asyncio.get_event_loop().run_until_complete(test_async())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions