ExaMetaData#

class pyexasol.ExaMetaData(connection)[source]#

Bases: object

This class implements lock-free metadata requests using /*snapshot execution*/ SQL hint, as described further in https://docs.exasol.com/db/latest/database_concepts/snapshot_mode.htm.

Note

If you still get locks, please make sure to update Exasol server to the latest minor version.

Examples

You may access these functions using .meta property of connection object.

>>> C = pyexasol.connect(...)
... print(C.meta.sql_columns('SELECT 1 AS id'))
execute_meta_nosql(meta_command, meta_params=None)[source]#

Execute no SQL metadata command introduced in Exasol 7.0+

Parameters:
  • meta_command – Metadata command.

  • meta_params – Parameters for metadata command.

Returns:

ExaStatement

Note

This feature requires WebSocket protocol v2 or higher

List of available commands can be found here.

execute_snapshot(query, query_params=None)[source]#

Execute query in snapshot transaction mode using SQL hint

Parameters:
  • query – SQL query text, possibly with placeholders.

  • query_params – Values for placeholders.

Returns:

ExaStatement

Warning

Please do not try to query normal tables with this method. It will fail during creation of indices or statistics objects.

Note

fetch_dict=Tru is enforced to prevent users from relying on order of columns in system views

list_columns(column_schema_pattern='%', column_table_pattern='%', column_object_type_pattern='%', column_name_pattern='%')[source]#

List Columns.

Parameters:
  • column_schema_pattern – Schema name or LIKE-pattern to filter on. (default: '%')

  • column_table_pattern – Table name or LIKE-pattern to filter on. (default: '%')

  • column_object_type_pattern – Object type or LIKE-pattern to filter on. (default: '%')

  • column_name_pattern – Column name or LIKE-pattern to filter on. (default: '%')

Returns:

List of columns from EXA_ALL_COLUMNS system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_indices(index_schema_pattern='%', index_table_pattern='%', index_owner_pattern='%')[source]#

List indicies.

Parameters:
  • index_schema_pattern – Schema name or LIKE-pattern to filter on. (default: '%')

  • index_table_pattern – Table name or LIKE-pattern to filter on. (default: '%')

  • index_owner_pattern – Owner name or LIKE-pattern to filter on. (default: '%')

Returns:

List of indices with sizes from EXA_ALL_INDICES system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_object_sizes(object_name_pattern='%', object_type_pattern='%', owner_pattern='%', root_name_pattern='%')[source]#

List Objects with their respective size.

Parameters:
  • object_name_pattern – Object name or LIKE-pattern to filter on. (default: '%')

  • object_type_pattern – Object type or LIKE-pattern to filter on. (default: '%')

  • owner_pattern – Owner name or LIKE-pattern to filter on. (default: '%')

  • root_name_pattern – Root name or LIKE-pattern to filter on.j It normally refers to schema name. (default: '%')

Returns:

List of objects with sizes from EXA_ALL_OBJECT_SIZES system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_objects(object_name_pattern='%', object_type_pattern='%', owner_pattern='%', root_name_pattern='%')[source]#

List Objects.

Parameters:
  • object_name_pattern – Object name or LIKE-pattern to filter on. (default: '%')

  • object_type_pattern – Object type or LIKE-pattern to filter on. (default: '%')

  • owner_pattern – Owner name or LIKE-pattern to filter on. (default: '%')

  • root_name_pattern – Root name or LIKE-pattern to filter on.j It normally refers to schema name. (default: '%')

Returns:

List of objects from EXA_ALL_OBJECTS system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_schemas(schema_name_pattern='%')[source]#

List Schemas.

Parameters:

schema_name_pattern – Schema name or LIKE-pattern to filter on. (default: '%')

Returns:

List of schemas from EXA_SCHEMAS system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_sql_keywords()[source]#

Get reserved SQL keywords which cannot be used as identifiers without double-quote escaping

Returns:

List of SQL keywords from EXA_SQL_KEYWORDS system view.

Warning

Never hardcode this list! It might change with next Exasol server version without warning

Note

These keywords cannot be used as identifiers without double quotes.

list_tables(table_schema_pattern='%', table_name_pattern='%')[source]#

List Tables.

Parameters:
  • table_schema_pattern – Schema name or LIKE-pattern to filter on. (default: '%')

  • table_name_pattern – Table name or LIKE-pattern to filter on. (default: '%')

Returns:

List of tables from EXA_ALL_TABLES system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

list_views(view_schema_pattern='%', view_name_pattern='%')[source]#

List Views.

Parameters:
  • view_schema_pattern – Schema name or LIKE-pattern to filter on. (default: '%')

  • view_name_pattern – Table name or LIKE-pattern to filter on. (default: '%')

Returns:

List of views from EXA_ALL_VIEWS system view matching LIKE-pattern.

Note

Patterns are case-sensitive. You may escape LIKE-patterns.

schema_exists(schema_name)[source]#

Check if schema exists.

Parameters:

schema_name – Name of the schema to check.

Returns:

True if the schema exists, otherwise False.

snapshot_execution_hint = '/*snapshot execution*/'#
sql_columns(query, query_params=None)[source]#

Get result set columns of SQL query without executing it

Parameters:
  • query – SQL query text, possibly with placeholders.

  • query_params – Values for placeholders.

Returns:

Columns of SQL query result without executing it. Output format is similar to pyexasol.ExaStatement.columns().

table_exists(table_name)[source]#

Check if table exists.

Parameters:

table_name –

Name of the table to check for. Can be one of:

  • str: table identifier.

  • tuple[str, ...]: schema-qualified table identifier, such as ("SCHEMA", "TABLE").

Returns:

True if the table exists, otherwise False.

view_exists(view_name)[source]#

Check if view exists.

Parameters:

view_name –

Name of the view to check for. Can be one of:

  • str: view identifier.

  • tuple[str, ...]: schema-qualified view identifier, such as ("SCHEMA", "VIEW").

Returns:

True if the view exists, otherwise False.