Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Open sql_destination_file in read mode
- sql_destination_file_1 = open(destination_path + destination_file, 'r', encoding = 'utf-16')
- # Read sql_destination_file readlines
- sql_destination_file_content_1 = sql_destination_file_1.readlines()
- # TEMP
- sql_copy_file = open(destination_path + 'SQL_copy.sql', 'w+', encoding = 'utf-16')
- # SQL Server connection
- SQLdbconnection = pyodbc.connect(r'DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + gfe_primavera_db_host + ';DATABASE=zrma;UID=' + gfe_primavera_db_username + ';PWD=' + gfe_primavera_db_password, autocommit=True)
- # Create a cursor from the connection
- SQLdbcursor = SQLdbconnection.cursor()
- for lines in sql_destination_file_content_1:
- # TEMP
- sql_copy_file.write('%s' % lines)
- # Print line by line
- #print ("%s" %lines)
- # Insert SQL to cursor along with SQL file
- SQLdbcursor.executemany(%lines)
- # Fetch the first row only
- #print(SQLdbcursor.fetchone())
- # Close cursor and connection
- SQLdbcursor.close()
- SQLdbconnection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement