sql
module provides helper functions for working with the database directly.
Function | Parameters | Return Value | Description |
---|---|---|---|
convert_date_to_planta_time(date, date_format=%d.%m.%Y) |
date: String containing a date date_format: A valid date format string |
The date converted to amount of days since 01.01.1970 | Converts a readable date into the format used by PLANTA date fields |
convert_planta_time_to_date(planta_time, date_format=%d.%m.%Y) |
planta_time: Days since 01.01.1970 date_format: A valid date format string |
A readable date as defined by the format | Converts the PLANTA internal date format to a readable string |
get_sql_date_format(planta_time) |
planta_time: Days since 01.01.1970 | Returns a string to be used in a sql statement | Converts the days since 01.01.1970 to a proper date string and then adds the dbms related code to make it valid sql |
sanitize_value(value) |
value: A value you want to insert into a SQL statement | A sanitized version of the value | Sanitizes a string that will later be formatted into a sql statement. Useful for preventing SQL injections or putting UUID objects into a statement |
from ppms.sql import convert_planta_time_to_date from ppms.constants import SYS_VAR_TODAY today = ppms.uvar_get(SYS_VAR_TODAY) today_as_date_string = convert_planta_time_to_date(planta_time=today) ppms.ui_message_box('Today is {}'.format(today_as_date_string))