aiida.orm.implementation.sql package¶
This module is for subclasses of the generic backend entities that only apply to SQL backends
All SQL backends with an ORM should subclass from the classes in this module
-
class
aiida.orm.implementation.sql.
SqlBackend
[source]¶ Bases:
typing.Generic
,aiida.orm.implementation.backends.Backend
- A class for SQL based backends. Assumptions are that:
- there is an ORM
- that it is possible to convert from ORM model instances to backend instances
- that psycopg2 is used as the engine
if any of these assumptions do not fit then just implement a backend from
aiida.orm.implementation.Backend
-
__abstractmethods__
= frozenset(['transaction', 'logs', 'migrate', 'execute_raw', 'computers', 'query_manager', 'comments', 'cursor', 'authinfos', 'groups', 'get_backend_entity', 'query', 'nodes', 'users'])¶
-
__args__
= None¶
-
__dict__
= dict_proxy({'_abc_cache': <_weakrefset.WeakSet object>, '__module__': 'aiida.orm.implementation.sql.backends', '__orig_bases__': (typing.Generic[~ModelType], <class 'aiida.orm.implementation.backends.Backend'>), 'execute_prepared_statement': <function execute_prepared_statement>, u'__origin__': None, 'execute_raw': <function execute_raw>, '__abstractmethods__': frozenset(['transaction', 'logs', 'migrate', 'execute_raw', 'computers', 'query_manager', 'comments', 'cursor', 'authinfos', 'groups', 'get_backend_entity', 'query', 'nodes', 'users']), '_abc_generic_negative_cache_version': 40, '__tree_hash__': 5926332592025, 'cursor': <function cursor>, '_abc_registry': <_weakrefset.WeakSet object>, '__args__': None, '_gorg': aiida.orm.implementation.sql.backends.SqlBackend, 'get_backend_entity': <function get_backend_entity>, '__dict__': <attribute '__dict__' of 'SqlBackend' objects>, '__next_in_mro__': <class 'aiida.orm.implementation.backends.Backend'>, '__parameters__': (~ModelType,), '_abc_generic_negative_cache': <_weakrefset.WeakSet object>, '__weakref__': <attribute '__weakref__' of 'SqlBackend' objects>, '__doc__': '\n A class for SQL based backends. Assumptions are that:\n * there is an ORM\n * that it is possible to convert from ORM model instances to backend instances\n * that psycopg2 is used as the engine\n\n if any of these assumptions do not fit then just implement a backend from :class:`aiida.orm.implementation.Backend`\n ', u'__extra__': None})¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sql.backends'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (typing.Generic[~ModelType], <class 'aiida.orm.implementation.backends.Backend'>)¶
-
__origin__
= None¶
-
__parameters__
= (~ModelType,)¶
-
__tree_hash__
= 5926332592025¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 40¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlBackend
-
cursor
()[source]¶ Return a psycopg cursor. This method should be used as a context manager i.e.:
with backend.cursor(): # Do stuff
Returns: a psycopg cursor Return type: psycopg2.extensions.cursor
-
execute_prepared_statement
(sql, parameters)[source]¶ Execute an SQL statement with optional prepared statements.
Parameters: - sql – the SQL statement string
- parameters – dictionary to use to populate the prepared statement
-
execute_raw
(query)[source]¶ Execute a raw SQL statement and return the result.
Parameters: query – a string containing a raw SQL statement Returns: the result of the query
-
get_backend_entity
(model)[source]¶ Return the backend entity that corresponds to the given Model instance
Parameters: model – the ORM model instance to promote to a backend instance Returns: the backend entity corresponding to the given model Return type: aiida.orm.implementation.BackendEntity
Submodules¶
Generic backend related objects
-
class
aiida.orm.implementation.sql.backends.
SqlBackend
[source]¶ Bases:
typing.Generic
,aiida.orm.implementation.backends.Backend
- A class for SQL based backends. Assumptions are that:
- there is an ORM
- that it is possible to convert from ORM model instances to backend instances
- that psycopg2 is used as the engine
if any of these assumptions do not fit then just implement a backend from
aiida.orm.implementation.Backend
-
__abstractmethods__
= frozenset(['transaction', 'logs', 'migrate', 'execute_raw', 'computers', 'query_manager', 'comments', 'cursor', 'authinfos', 'groups', 'get_backend_entity', 'query', 'nodes', 'users'])¶
-
__args__
= None¶
-
__dict__
= dict_proxy({'_abc_cache': <_weakrefset.WeakSet object>, '__module__': 'aiida.orm.implementation.sql.backends', '__orig_bases__': (typing.Generic[~ModelType], <class 'aiida.orm.implementation.backends.Backend'>), 'execute_prepared_statement': <function execute_prepared_statement>, u'__origin__': None, 'execute_raw': <function execute_raw>, '__abstractmethods__': frozenset(['transaction', 'logs', 'migrate', 'execute_raw', 'computers', 'query_manager', 'comments', 'cursor', 'authinfos', 'groups', 'get_backend_entity', 'query', 'nodes', 'users']), '_abc_generic_negative_cache_version': 40, '__tree_hash__': 5926332592025, 'cursor': <function cursor>, '_abc_registry': <_weakrefset.WeakSet object>, '__args__': None, '_gorg': aiida.orm.implementation.sql.backends.SqlBackend, 'get_backend_entity': <function get_backend_entity>, '__dict__': <attribute '__dict__' of 'SqlBackend' objects>, '__next_in_mro__': <class 'aiida.orm.implementation.backends.Backend'>, '__parameters__': (~ModelType,), '_abc_generic_negative_cache': <_weakrefset.WeakSet object>, '__weakref__': <attribute '__weakref__' of 'SqlBackend' objects>, '__doc__': '\n A class for SQL based backends. Assumptions are that:\n * there is an ORM\n * that it is possible to convert from ORM model instances to backend instances\n * that psycopg2 is used as the engine\n\n if any of these assumptions do not fit then just implement a backend from :class:`aiida.orm.implementation.Backend`\n ', u'__extra__': None})¶
-
__extra__
= None¶
-
__module__
= 'aiida.orm.implementation.sql.backends'¶
-
__next_in_mro__
¶
-
__orig_bases__
= (typing.Generic[~ModelType], <class 'aiida.orm.implementation.backends.Backend'>)¶
-
__origin__
= None¶
-
__parameters__
= (~ModelType,)¶
-
__tree_hash__
= 5926332592025¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_generic_negative_cache_version
= 40¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_gorg
¶ alias of
SqlBackend
-
cursor
()[source]¶ Return a psycopg cursor. This method should be used as a context manager i.e.:
with backend.cursor(): # Do stuff
Returns: a psycopg cursor Return type: psycopg2.extensions.cursor
-
execute_prepared_statement
(sql, parameters)[source]¶ Execute an SQL statement with optional prepared statements.
Parameters: - sql – the SQL statement string
- parameters – dictionary to use to populate the prepared statement
-
execute_raw
(query)[source]¶ Execute a raw SQL statement and return the result.
Parameters: query – a string containing a raw SQL statement Returns: the result of the query
-
get_backend_entity
(model)[source]¶ Return the backend entity that corresponds to the given Model instance
Parameters: model – the ORM model instance to promote to a backend instance Returns: the backend entity corresponding to the given model Return type: aiida.orm.implementation.BackendEntity