GlobalParam.get_mariadb_user(), GlobalParam.get_mariadb_password()) execute_sql(maria_connection, create_table_sql, False) maria_connection.close() postgresql_connection = connect_to_databases(GlobalParam.get_pgsql_url(), GlobalParam.get_pgsql_user(), GlobalParam.get_pgsql_password()) execute_sql(postgresql_connection, create_table_sql, False) postgresql_connection.close() # read excel sheet datasets then insert into database table insert_many_sql = ''' INSERT INTO movie (id, name, chnname, main_cast, year, region, type, viewed, want_to_review) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ''' data = read_excel(GlobalParam.get_excel_datasets(), 'movie', True, dtype=str) maria_connection = connect_to_databases(GlobalParam.get_mariadb_url(), GlobalParam.get_mariadb_user(), GlobalParam.get_mariadb_password()) execute_sql(maria_connection, insert_many_sql, False, data) maria_connection.close() postgresql_connection = connect_to_databases(GlobalParam.get_pgsql_url(), GlobalParam.get_pgsql_user(), GlobalParam.get_pgsql_password()) execute_sql(postgresql_connection, insert_many_sql, False, data) postgresql_connection.close() # connection to mysql, postgresql and write query sql results to excel sheet query_sql = 'select * from movie' maria_connection = connect_to_databases(GlobalParam.get_mariadb_url(), GlobalParam.get_mariadb_user(),
from python_common.global_param import GlobalParam from datasets.datasets_utils import read_excel # read excel, use converters decide column type, if all column type is str, # function equals:read_excel(excel_datasets, 'movie', True, dtype=str) result = read_excel(GlobalParam.get_excel_datasets(), 'movie_maria', True, converters={ 'id': int, 'name': str, 'chnname': str, 'main_cast': str, 'year': str, 'region': str, 'type': str, 'viewed': str, 'want_to_review': str }) print(result)