SQL source
- pydantic model crudcreator.source.source.SQLSource.SQLSource[source]
Represents a type of entity that is plugged directly into an SQL database. It therefore represents an SQL table (not a database, but a table).
Example of descriptor :
{ "name": "SQLSource", "params": { "engine_wrapper": "$engine_wrapper$" }, "interface": { "name": "book", "fields": [ { "name": "book_id", "is_id_field": true, "can_be_created": true, "can_be_updated": false }, { "name": "title", "is_id_field": false, "can_be_created": true, "can_be_updated": true }, { "name": "public_domain", "is_id_field": false, "can_be_created": true, "can_be_updated": false } ] } }
With “engine_wrapper” a substitution defined, for example, as follows:
from sqlalchemy import create_engine engine = create_engine( f"postgresql+pg8000://{settings.postgres_username}:{settings.postgres_password}@{settings.postgres_host}:{settings.postgres_port}/{settings.postgres_database}", echo=False ) engine_wrapper = SQLEngineSyncWrapper(engine=engine)
- field params: SQLSourceParams [Required][source]
Source parameters.
- field sql_inspector: SQLColumnInspector | None = None[source]
A utility that allows us to analyze the source (among other things, to complete the interface attribute). Will be built by get_inspector. Will be used by proxies built on top of this one.
- async complete() SQLSource [source]
Completes the “interface” attribute with information that can be retrieved from the SQL database.
- Return type:
- async get_inspector() SQLColumnInspector [source]
Returns the sql_inspector. Builds it if it has not already been built.
- Return type:
- pydantic model crudcreator.source.source.SQLSource.SQLSourceParams[source]
- field engine_wrapper: AbstractSQLEngineWrapper [Required][source]
L’objet qui permet à CRUDCreator d’interagir avec la base de données SQL.
Engine wrapper
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLEngineWrapper.AbstractSQLEngineWrapper[source]
Wraps an SQLAlchemy engine.
- begin() Iterator[AbstractSQLConnectionWrapper] [source]
To be implemented in a child class. Creates a connection and initiates a transaction with the database.
- Return type:
Iterator[AbstractSQLConnectionWrapper]
- inspect() AbstractSQLInspectorWrapper [source]
Returns the object wrapping an SQLAlchemy Inspector.
- Return type:
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLEngineWrapper.SQLEngineSyncWrapper[source]
Wraps a synchronous SQLAlchemy engine (but the interface remains asynchronous).
- begin() Iterator[SQLConnectionSyncWrapper] [source]
Creates a connection and initiates a transaction with the database.
- Return type:
Iterator[SQLConnectionSyncWrapper]
- inspect() SQLInspectorSyncWrapper [source]
Returns the object wrapping an SQLAlchemy Inspector.
- Return type:
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLEngineWrapper.SQLEngineAsyncWrapper[source]
Wraps a asynchronous SQLAlchemy engine.
- begin() Iterator[SQLConnectionAsyncWrapper] [source]
Creates a connection and initiates a transaction with the database.
- Return type:
Iterator[SQLConnectionAsyncWrapper]
- inspect() SQLInspectorAsyncWrapper [source]
Returns the object wrapping an SQLAlchemy Inspector.
- Return type:
Connection wrapper
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLConnectionWrapper.AbstractSQLConnectionWrapper[source]
Wraps an SQLAlchemy connection.
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLConnectionWrapper.SQLConnectionSyncWrapper[source]
Wraps a synchronous SQLAlchemy connection (but the interface remains asynchronous)
Inspector wrapper
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLInspectorWrapper.AbstractSQLInspectorWrapper[source]
Wraps an SQLAlchemy inspector.
- pydantic model crudcreator.adaptator.sql.engine_wrapper.SQLInspectorWrapper.SQLInspectorSyncWrapper[source]
Wraps an SQLAlchemy inspector from a synchronous engine (but the interface remains asynchronous)
SQLColumnInspector
- pydantic model crudcreator.adaptator.sql.SQLColumnInspector.SQLColumnInspector[source]
A utility for analyzing an SQL table.
- field index_column: dict[str, SQLColumn] [Required][source]
Set by the build. An index that associates the name of a column with its information.
- field index_sqlalchemy_column: dict[str, Column] [Required][source]
Set by the build function. An index that associates the name of a column with the corresponding SQLAlchemy column.
- field list_column: list[SQLColumn] [Required][source]
Set by the build function. List of table columns and corresponding information.
- field list_sqlalchemy_column: list[Column] [Required][source]
Set by the build function. The list of SQLAlchemy columns (used to build queries, for example).
- async static build_from_interface(
- sqlalchemy_engine_wrapper: AbstractSQLEngineWrapper,
- source_interface: SQLEntityTypeInterface,
Builds the inspector.
- Parameters:
sqlalchemy_engine_wrapper (AbstractSQLEngineWrapper) –
source_interface (SQLEntityTypeInterface) –
- join_inspector(
- other_inspector: SQLColumnInspector,
Creates the inspector associated with a virtual table created by joining two other tables.
- Parameters:
other_inspector (SQLColumnInspector) –
- Return type: