Error in Pipeline Script block

I am new to Ignition, Can anyone help me out.
I am trying to bring email id from database and sending email with Script block in pipeline.I am getting error massage as Error executing scripting block in logs. I am triggering script block with Switch block then Script block will start executive and have to send email to the user.Can u please tell me can i send email with Script block without notification block for dynamic users.

The following is Script which is written in Script block.

query = system.db.runScalarQuery(" SELECT email_id FROM database.userlist where user_id = 2")
recipients = [query]
body = “Hello, this is an email”
smpt = “”“”,"", “Here is the email!”, body, 0, recipients)

It looks like this part is where your error is. For scripts, I’d recommend using the script playground tool to get them working first.

This should instead be something like this (not in front of pc to check):

#edit: this won't work, need to convert query to a pydataset, or use an incrementer and then val.getValueAt(i,0)
recipients = [Val.getValueAt(0) for Val in query]

I have tried what you suggested but its shows same error.

Did you try the script in the scrip playground tool?
Also sorry, my late-night brain failed me.

Use this:

recipients = [row[0] for row in system.dataset.toPyDataset(query)]

#or this
recipients = [query.getValueAt(i,0) for i in range(query.getRowCount())] 

Thanks you for your respond.
Actually i am working in Alarm Notification Pipeline.
Yes i was tested in Script console.But i am unable to get dataset from database.

I am getting like this in Script console.

Traceback (most recent call last):
File “”, line 2, in
AttributeError: ‘int’ object has no attribute ‘getRowCount’

Actually, you were right in your first post: the scalar function just returns a single value. Go back to that but include the database name as the 2nd argument.