Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Issue with UUID columns when using Databases
import asyncio
from sqlalchemy import MetaData, Table, Column, Float
from sqlalchemy.dialects.postgresql import UUID
from databases import Database
database = Database("postgresql://test@")
metadata = MetaData()
activities = Table(
Column("id", UUID(as_uuid=False), primary_key=True), # Results in: [{'id': UUID('348beab0-34dc-11e7-8762-1b7a0b79ec0c'), 'points': 6.667}]
# Column("id", UUID(as_uuid=True), primary_key=True), # Results in: AttributeError: 'UUID' object has no attribute 'replace'
Column("points", Float),
async def run_query():
await database.connect()
query =
rows = await database.fetch_all(query=query)
content = [
{"id": row[], "points": row[activities.c.points]} for row in rows
return content
if __name__ == "__main__":
json =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.