ralsei.jinja
¶
Package Contents¶
Classes¶
Transform values into their SQL representation |
|
Represents an imported template (see |
|
Compiled jinja template that can be rendered |
|
Type-aware jinja environment for rendering SQL |
|
Layer on top of |
|
Interface describing a |
API¶
- class ralsei.jinja.SqlAdapter¶
Transform values into their SQL representation
Initialization
- register_type(type_: type[ralsei.jinja.adapter.SqlAdapter.register_type.T], to_sql: collections.abc.Callable[[ralsei.jinja.adapter.SqlAdapter.register_type.T], str])¶
Register SQL renderer function for a type
- format(source: str, /, *args, **kwargs) str ¶
Similar to
str.format()
, but appliesto_sql()
to each parameter
-
class ralsei.jinja.SqlTemplateModule(template: jinja2.environment.Template, context: jinja2.runtime.Context, body_stream: collections.abc.Iterable[str] | None =
None
)¶ Bases:
jinja2.environment.TemplateModule
Represents an imported template (see
jinja2.Template.module
)All the exported names of the template are available as attributes on this object.
Initialization
- render_sql() sqlalchemy.sql.elements.TextClause ¶
Render and wrap with
sqlalchemy.sql.expression.text()
- render_sql_split() list[sqlalchemy.sql.elements.TextClause] ¶
Render as multiple statements, splitting on
{%split%}
tag, wrap withsqlalchemy.sql.expression.text()
- class ralsei.jinja.SqlTemplate¶
Bases:
jinja2.Template
Compiled jinja template that can be rendered
- render_sql(*args: Any, **kwargs: Any) sqlalchemy.sql.elements.TextClause ¶
Render and wrap in
sqlalchemy.sql.expression.text()
- render_split(*args: Any, **kwargs: Any) list[str] ¶
Render as multiple statements, splitting on
{%split%}
tag
- render_sql_split(*args: Any, **kwargs: Any) list[sqlalchemy.sql.elements.TextClause] ¶
Render as multiple statements, splitting on
{%split%}
tag, wrap insqlalchemy.sql.expression.text()
-
class ralsei.jinja.SqlEnvironment(dialect_info: ralsei.dialect.DialectInfo =
BaseDialectInfo
)¶ Bases:
jinja2.Environment
Type-aware jinja environment for rendering SQL
- Parameters:¶
- dialect_info: ralsei.dialect.DialectInfo =
BaseDialectInfo
¶ dialect-specific settings
- dialect_info: ralsei.dialect.DialectInfo =
Initialization
- property adapter : ralsei.jinja.adapter.SqlAdapter¶
Type adapter that turns values in braces (like
{{value}}
) into SQL strings
- property dialect_info : ralsei.dialect.DialectInfo¶
Dialect-specific settings
-
from_string(source: str | jinja2.nodes.Template, globals: collections.abc.MutableMapping[str, Any] | None =
None
, template_class: type[jinja2.Template] | None =None
) jinja2.Template ¶ See
jinja2.Environment.from_string()
By default, the template class will be
SqlTemplate
- render(source: str, /, *args: Any, **kwargs: Any) str ¶
Render template once, shorthand for
self.from_string().render()
- render_sql(source: str, /, *args: Any, **kwargs: Any) sqlalchemy.sql.elements.TextClause ¶
Render and wrap with
sqlalchemy.sql.expression.text()
- render_split(source: str, /, *args: Any, **kwargs: Any) list[str] ¶
Render as multiple statements, splitting on
{%split%}
tag
- render_sql_split(source: str, /, *args: Any, **kwargs: Any) list[sqlalchemy.sql.elements.TextClause] ¶
Render as multiple statements, splitting on
{%split%}
tag, wrap withsqlalchemy.sql.expression.text()
- property base : ralsei.jinja.environment.SqlEnvironment¶
- class ralsei.jinja.SqlEnvironmentWrapper(env: ralsei.jinja.environment.SqlEnvironment, locals: dict[str, Any])¶
Layer on top of
ralsei.jinja.SqlEnvironment
with extra local variables- Parameters:¶
Initialization
- property adapter : ralsei.jinja.adapter.SqlAdapter¶
Type adapter that turns values in braces (like
{{value}}
) into SQL strings
- property dialect_info : ralsei.dialect.DialectInfo¶
Dialect-specific settings
-
from_string(source: str | jinja2.nodes.Template, globals: collections.abc.MutableMapping[str, Any] | None =
None
, template_class: None =None
) ralsei.jinja.environment.SqlTemplate ¶ See
jinja2.Environment.from_string()
By default, the template class will be
SqlTemplate
- render(source: str, /, *args: Any, **kwargs: Any) str ¶
Render template once, shorthand for
self.from_string().render()
- render_sql(source: str, /, *args: Any, **kwargs: Any) sqlalchemy.sql.elements.TextClause ¶
Render and wrap with
sqlalchemy.sql.expression.text()
- render_split(source: str, /, *args: Any, **kwargs: Any) list[str] ¶
Render as multiple statements, splitting on
{%split%}
tag
- render_sql_split(source: str, /, *args: Any, **kwargs: Any) list[sqlalchemy.sql.elements.TextClause] ¶
Render as multiple statements, splitting on
{%split%}
tag, wrap withsqlalchemy.sql.expression.text()
- property base : ralsei.jinja.environment.SqlEnvironment¶
The base environment
- class ralsei.jinja.ISqlEnvironment¶
Bases:
typing.Protocol
Interface describing a
ralsei.jinja.SqlEnvironment
like object(including
ralsei.jinja.SqlEnvironmentWrapper
)- property adapter : ralsei.jinja.adapter.SqlAdapter¶
Type adapter that turns values in braces (like
{{value}}
) into SQL strings
- property dialect_info : ralsei.dialect.DialectInfo¶
Dialect-specific settings
-
from_string(source: str | jinja2.nodes.Template, globals: collections.abc.MutableMapping[str, Any] | None =
None
, template_class: None =None
) ralsei.jinja.environment.SqlTemplate ¶ See
jinja2.Environment.from_string()
By default, the template class will be
SqlTemplate
- render(source: str, /, *args: Any, **kwargs: Any) str ¶
Render template once, shorthand for
self.from_string().render()
- render_sql(source: str, /, *args: Any, **kwargs: Any) sqlalchemy.sql.elements.TextClause ¶
Render and wrap with
sqlalchemy.sql.expression.text()
- render_split(source: str, /, *args: Any, **kwargs: Any) list[str] ¶
Render as multiple statements, splitting on
{%split%}
tag
- render_sql_split(source: str, /, *args: Any, **kwargs: Any) list[sqlalchemy.sql.elements.TextClause] ¶
Render as multiple statements, splitting on
{%split%}
tag, wrap withsqlalchemy.sql.expression.text()
- property base : ralsei.jinja.environment.SqlEnvironment¶
The base environment