Skip to content

execute_scalar

execute_scalar 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.

from pydapper import connect

with connect() as commands:
    owner_name = commands.execute_scalar("select name from owner")

print(owner_name)
# Zach Schumacher
(This script is complete, it should run "as is")