Skip to content

Implement a .get on asyncpg.Record #330

Closed
@modelmat

Description

@modelmat

I have the following psuedocode:

record = database_pool.fetchval("some_sql") or {} # this is so I don't have to do `if result is None`
final = dict(record).get("column")

What I would like to see however, is a record.get function (similar to the dict.get())
The default argument should be used if a column is NULL, similar to dict.get()
This would allow for:

final = record.get("column", other_var)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions