Mosql.SQL (mosql v0.1.0)
Link to this section Summary
Functions
SQL for adding a new column if it does not exists
Generates upsert SQL statement for a given schema and a list of values of values INSERT INTO <table_name> (column1, column2...) VALUES (value1, value2...), (value1, value2...), (value1, value2...).... ON CONFLICT (primary_key_field) DO UPDATE SET column = EXCLUDED.column...;
Generates a SQL string for creating a table if not exists
Generates a SQL string for creating a table
SQL for drop table
Prepare the SQL DB for the full export. It performs the following 3 steps
SQL for removing a column if it does exists
Generates a SQL string for checking if a table exists in the schema
Construct the insert values for a given schema and a mongo document
SQL for truncate table
Generates upsert SQL statement for a given schema and a mongo document INSERT INTO <table_name> (column1, column2...) VALUES (value1, value2...) ON CONFLICT (primary_key_field) DO UPDATE SET column = EXCLUDED.column...;
Link to this section Functions
add_column_if_not_exists_sql(schema, column)
SQL for adding a new column if it does not exists
alter_table(schema, db_name)
alter_tables(export)
bulk_upsert_sql(schema, values)
Generates upsert SQL statement for a given schema and a list of values of values INSERT INTO <table_name> (column1, column2...) VALUES (value1, value2...), (value1, value2...), (value1, value2...).... ON CONFLICT (primary_key_field) DO UPDATE SET column = EXCLUDED.column...;
create_table_if_not_exists_sql(schema)
Generates a SQL string for creating a table if not exists
create_table_with_columns_sql(schema)
Generates a SQL string for creating a table
CREATE TABLE [IF NOT EXISTS] table_name (
column1 datatype(length) column_contraint,
column2 datatype(length) column_contraint,
column3 datatype(length) column_contraint,
...
table_constraints
);
drop_table_sql(schema)
SQL for drop table
filter_missing_columns(schema_columns, existing_columns)
filter_new_columns(schema_columns, existing_columns)
mongo_to_sql_type(mongo_type)
prepare(export)
Prepare the SQL DB for the full export. It performs the following 3 steps:
1. Truncate data from tables if exists
2. Create new tables, if not exists
3. Alter existing tables, if schema changed
remove_column_if_exists_sql(schema, column)
SQL for removing a column if it does exists
table_columns(db, table)
table_exists(schema)
table_exists_sql(schema)
Generates a SQL string for checking if a table exists in the schema
to_insert_values(schema, mongo_document \\ %{})
Construct the insert values for a given schema and a mongo document
truncate_table_sql(schema)
SQL for truncate table
upsert_document_sql(schema, mongo_document \\ %{})
Generates upsert SQL statement for a given schema and a mongo document INSERT INTO <table_name> (column1, column2...) VALUES (value1, value2...) ON CONFLICT (primary_key_field) DO UPDATE SET column = EXCLUDED.column...;