Table Of Contents

mitto.iov2.steps.CreateTable

Parameters

class mitto.iov2.steps.builtin.CreateTable(environ, max_varchar_length=65536, **kwargs)[source]

Bases: mitto.iov2.steps.base.BaseStep

Create an output database table from SDL.

Parameters
  • environ – The Mitto job’s environment. It is an error to provide a value for this parameter in a job configuration – Mitto provides this value automatically.

  • max_varchar_length (int) – Maximum length of strings that can be saved in a column with type VARCHAR. If a column contains string values longer than this, the column will be assigned a type of TEXT. The default value is 65,536.

  • kwargs (Dict[str, Any]) –

    A dict containing additional keys/values that are passed to mitto.iov2.db.todb() via that function’s kwargs argument.

    Currently, the only supported key/value pair is batch_size, which controls the number of rows sent to the database at a single time. The default value is 5,000.

Examples

Examples of using CreateTable as a step in a Mitto job configuration.

Example One – use default values
"steps": [
   ...
   {
       "use": "mitto.iov2.steps.CreateTable"
   },
   ...
]
Example Two – override default values
"steps": [
   ...
   {
       "use": "mitto.iov2.steps.CreateTable",
       "max_varchar_length": 16384,
       "batch_size": 10000
   },
   ...
]
DROP = ‘DROP TABLE IF EXISTS {};’
RENAME = ‘ALTER TABLE {} RENAME TO “{}”’
property is_sqlserver

Determine whether or not the engine is MS SQLServer

property is_mysql

Determine whether the engine is MySQL.

property alter_alter

Generate the ALTER TABLE SQL in the correct dialect

property alter_add

Generate ‘ALTER TABLE … ADD …’ SQL in the correct dialect

get_drop_str(table)[source]

Constructs a DROP statement string with schema and table name. Full table name is escaped regarding the engine’s dialect e.g. for the PostgreSQL it will return:

DROP TABLE IF EXISTS “schema”.”table_name”;

Return type

str

get_rename_str(old_table, new_table)[source]

Constructs a RENAME statement string with schema and table name. Full table name is escaped regarding the engine’s dialect e.g. for the PostgreSQL it will return:

ALTER TABLE “schema.table_name” RENAME TO table_name;

Return type

str