Skip to content

execute_scalar_async

execute_scalar_async executes the query, and returns the first column of the first row in the result set returned by the query. The additional columns or rows are ignored.

Parameters🔗

name type description optional default
sql str the sql query str to execute 👎
param ParamType params to substitute in the query 👍 None

Example🔗

Get the name of the first task owner in the database.

import asyncio

from pydapper import connect_async


async def main():
    async with connect_async() as commands:
        owner_name = await commands.execute_scalar_async("select name from owner")

    print(owner_name)
    # Zach Schumacher


asyncio.run(main())
(This script is complete, it should run "as is")