sql_safety
Classes:
SafeSQLName
SafeSQLName()
Methods:
-
create_column_name
–Create an SQL-safe column name for the Pydantic data field.
-
create_table_name
–Create SQL-safe table name for the record's data model.
-
remove_characters
–Simplify and remove undesirable characters from a string.
create_column_name
create_column_name(field_name: str, field_type: str) -> str
Create an SQL-safe column name for the Pydantic data field.
Parameters:
-
field_name
str
) –Displayed name of the field (detail) in Heurist.
-
field_type
str
) –Heurist type of the field (detail).
Returns:
-
str
(str
) –SQL-safe column name.
create_table_name
create_table_name(record_name: str) -> str
Create SQL-safe table name for the record's data model.
Examples:
heurist_name = "Sequence" SafeSQLName().create_table_name(heurist_name) 'SequenceTable'
Parameters:
-
record_name
str
) –Name of the Heurist record type.
Returns:
-
str
(str
) –SQL-safe name for the record type's table.
remove_characters
classmethod
remove_characters(s: str) -> str
Simplify and remove undesirable characters from a string.
Examples:
s = "Author or Creator (Person, Organization)" SafeSQLName.remove_characters(s) 'Author or Creator'
s = "Status_trad_freetext" SafeSQLName.remove_characters(s) 'Status_trad_freetext'
Parameters:
-
s
str
) –Input string.
Returns:
-
str
(str
) –Cleaned string.