ralsei.types
¶
Package Contents¶
Classes¶
Interface for an object that renders to SQL inside a jinja template |
|
Raw SQL string, inserted into the template as-is |
|
A SQL identifier, like |
|
Table identifier, like |
|
Placeholder for a bind parameter, like |
|
Base class for |
|
Column template class |
|
Rendered column class |
|
Renders to |
|
Column and its associated value, base class for |
|
Column template class with an associated value |
|
Rendered column class with an associated value |
|
Renders to |
|
Column name and its associated value, used inside a WHERE clause for locating a row |
API¶
- class ralsei.types.ToSql¶
Bases:
abc.ABC
Interface for an object that renders to SQL inside a jinja template
- abstract to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
Render to SQL string
- class ralsei.types.Sql¶
Bases:
ralsei.types.to_sql.ToSql
Raw SQL string, inserted into the template as-is
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
- class ralsei.types.Identifier¶
Bases:
ralsei.types.to_sql.ToSql
A SQL identifier, like
"table_name"
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
- class ralsei.types.Table¶
Bases:
ralsei.types.to_sql.ToSql
Table identifier, like
"schema_name"."table_name"
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
- class ralsei.types.Placeholder¶
Bases:
ralsei.types.to_sql.ToSql
Placeholder for a bind parameter, like
:value
Must not any spaces or special characters
- __post_init__()¶
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
- class ralsei.types.ColumnBase(name: str)¶
Bases:
abc.ABC
Base class for
Column
andColumnRendered
Initialization
- property identifier : ralsei.types.primitives.Identifier¶
name
wrapped in a SQL identifier
- abstract render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.column.ColumnRendered ¶
Turn into the rendered version
- class ralsei.types.Column(name: str, type: str)¶
Bases:
ralsei.types.column.ColumnBase
Column template class
- Parameters:¶
Initialization
- render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.column.ColumnRendered ¶
Render the type template
- class ralsei.types.ColumnRendered(name: str, type: str)¶
Bases:
ralsei.types.column.ColumnBase
Rendered column class
- Parameters:¶
Initialization
-
type : ralsei.types.primitives.Sql =
None
¶
- property definition : ralsei.types.column.ColumnDefinition¶
As column definition (name + type)
- render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.column.ColumnRendered ¶
- class ralsei.types.ColumnDefinition(column: ralsei.types.column.ColumnRendered)¶
Bases:
ralsei.types.to_sql.ToSql
Renders to
table_name TYPE
, for use in table definitionsInitialization
-
column : ralsei.types.column.ColumnRendered =
None
¶
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
-
column : ralsei.types.column.ColumnRendered =
-
class ralsei.types.ValueColumnBase(name: str, value: Any =
FROM_NAME
)¶ Bases:
ralsei.types.column.ColumnBase
Column and its associated value, base class for
ValueColumn
andValueColumnRendered
- Parameters:¶
- name: str¶
column name
- value: Any =
FROM_NAME
¶ value that will be applied to the column
By default, will be set to a
ralsei.types.Placeholder
with the same name as the column
Initialization
- property set_statement : ralsei.types.value_column.ValueColumnSetStatement¶
As set statement (name = value)
- abstract render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.value_column.ValueColumnRendered ¶
Turn into the rendered version
-
class ralsei.types.ValueColumn(name: str, type: str, value: Any =
FROM_NAME
)¶ Bases:
ralsei.types.column.Column
,ralsei.types.value_column.ValueColumnBase
Column template class with an associated value
- Parameters:¶
Initialization
- render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.value_column.ValueColumnRendered ¶
Render the type template
-
class ralsei.types.ValueColumnRendered(name: str, type: str, value: Any =
FROM_NAME
)¶ Bases:
ralsei.types.column.ColumnRendered
,ralsei.types.value_column.ValueColumnBase
Rendered column class with an associated value
- Parameters:¶
Initialization
- render(env: ralsei.jinja.ISqlEnvironment, /, **params: Any) ralsei.types.value_column.ValueColumnRendered ¶
- class ralsei.types.ValueColumnSetStatement(value_column: ralsei.types.value_column.ValueColumnBase)¶
Bases:
ralsei.types.to_sql.ToSql
Renders to
name = value
, for use in UPDATE statementsInitialization
-
value_column : ralsei.types.value_column.ValueColumnBase =
None
¶
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶
-
value_column : ralsei.types.value_column.ValueColumnBase =
-
class ralsei.types.IdColumn(name: str, value: Any =
FROM_NAME
)¶ Bases:
ralsei.types.to_sql.ToSql
Column name and its associated value, used inside a WHERE clause for locating a row
Renders to
name = value
- Parameters:¶
- name: str¶
column name
- value: Any =
FROM_NAME
¶ value that uniquely identifies a row
By default, will be set to a
ralsei.types.Placeholder
with the same name as the column
Initialization
- property identifier : ralsei.types.primitives.Identifier¶
name
wrapped in a SQL identifier
- to_sql(env: ralsei.jinja.ISqlEnvironment) str ¶