def mysql_query_drop(table: str) -> str: """Generate a bespoke drop query. :param table: the MySQL table. :return: the MySQL query """ queries = MysqlQueries() return queries.drop(table)
def mysql_query_insert(table: str, columns: List, col_types: List) -> str: """Generate a bespoke insert query. :param table: the MySQL table. :param columns: the list of columns. :param col_types: the list of column types for columns. :return: the MySQL query """ queries = MysqlQueries() return queries.insert(table, columns, col_types)
def exists_mysql(db_schema: str, db_table: str) -> bool: """Check if MySQL table exists. :param db_schema: the MySQL database schema. :param db_table: the MySQL table. :return: indicates if the file exists. """ queries = MysqlQueries() query = queries.exists_table(db_table) output = ReadersWriters.load_mysql_query(query, db_schema, dataframing=True) return output is not None and len(output) > 0
def exists_mysql_column(db_schema: str, db_table: str, column: str) -> bool: """Check if a column exists in a MySQL table. :param db_schema: the MySQL database schema. :param db_table: the MySQL table. :param column: name of the column. :return: indicates if the column exists. """ queries = MysqlQueries() query = queries.exists_column(db_table, column) output = ReadersWriters.load_mysql_query(query, db_schema, dataframing=True) return output is not None and len(output) > 0
def mysql_query_create( table: str, columns: List, col_types: List, defaults: List, primary_keys: List = list(), unique_keys: List = list(), meta: str = "ENGINE=InnoDB DEFAULT CHARSET=latin1") -> str: """Generate a bespoke create query. :param table: the MySQL table. :param columns: the list of columns. :param col_types: the list of column types for columns. :param defaults: the list of default values for columns. :param primary_keys: the list of primary keys for the table. :param unique_keys: the list of unique keys for the table. :param meta: the table metadata (Engine and charset). :return: the MySQL query """ queries = MysqlQueries() return queries.create(table, columns, col_types, defaults, primary_keys, unique_keys, meta)