Parameters¶
The PySQLX-Engine supports the parameters. The parameters are passed as a dictionary to the functions below.
queryquery_firstquery_as_dictquery_first_as_dictexecute
These functions are described in the Documentation for methods section.
Parameters are has prepared statements, where the values are converted to rust types and then to SQL types.
Python types > Rust types > SQL types
Note
In development mode, the SQL statements are printed in the console with the parameters builded and raw SQL. But the SQL builded with the parameters is not sent to the database.
The PySQLXEngine supports many Python types with automatic conversion to SQL.
Parameters types¶
Key: dict key must be a valid string.
Value: dict value can be one of the types bellow:
boolbytesdatedatetimeDecimaldictfloatintliststrtimetupleUUIDenum.EnumNone
These types are converted to the corresponding SQL type. This applies to parameters chained in a list or dict that are converted to json.
Example¶
For this example, the table users will be used. The table users has the following structure:
Create a main.py file and add the code examples below.
Running the code using the terminal