Gateway event script db query help

Hi all,
I am new to scripting and wanted to return a value from a database using gateway event script timer. Here is my script…the syntax is wrong. Please help out! I am thinking I need to use a name query but not sure how to write that.
#Cell01
Cell01 = system.tag.readBlocking(["[default]CELL01/FOLDER01/TT01)"])[0]
If (Cell01.value <> 0):
pWeight = SELECT CC.Weight FROM mytable01 CC
WHERE CC.active = 1 AND CC.tool_number = Cell01.value;

Thank you
Blue

Probably this might help.

https://docs.inductiveautomation.com/display/DOC81/system.db.runScalarPrepQuery

Thank you thecesrom, this is the code now but i am getting an error, result01 not define

Cell01 = system.tag.readBlocking(["[default]CELL01/FOLDER01/TT01"])[0]
if (Cell01.value <> 0):
Result01 = system.db.runScalarPrepQuery(“SELECT CC.weight FROM mytable01 CC WHERE CC.active = 1 AND CC.tool_number = ?”, [Cell01.value])
print result01

nevermind found the error, upper and lower case
Thank you