Good day I have a doubt, I have a code generated in Python which he does is to query a MySQL table named INFORMATION_SCHEMA.PROCESSLIST as follows:
SELECT *, IF (time> = 10, "Bad", "Good") AS State FROM INFORMATION_SCHEMA.PROCESSLIST WHERE id <> connection_id ();
Once this fulfills my conditions by means of python code I tell you to save those processes and also kill them with the command KILL, but the data that I send to make them in a table that creates in MySQL.
Now what I want is to continue browsing in MySQl, but I want to know if there is any way to save the queried data to a table but to SQL Server, basically query MySQL and save it to SQL Server.
Annex the code:
#! / Usr / bin / python
# - * - coding: UTF-8 - * -
Import os, sys
Import signal, os, sys
Import MySQLdb
connection_mysql = MySQLdb.connect (host = '10 .248.204.43 ', user =' root ', passwd =' sahc ', db =' Library ')
cur = conexion_mysql.cursor ()
query = ('SELECT *, IF (time> = 10,' Bad ',' Good ') AS State FROM INFORMATION_SCHEMA.PROCESSLIST WHERE id <> connection_id ()')
cur.execute (query)
for row in cur.fetchall ():
result = row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]
sql = "INSERT INTO test VALUES (" + str (row [0]) + "," + "'" + (row [1] or' ') + "'" + "," + " [2] or "+", "+", "+", "+ (row [3] or '') +" '"+", "+" ) + "," + "," + "," + ", +", "+", "(Row [6] or '') [7] or '') + "'" + "," + "now ()" + ")"
cur.execute (sql)
connection_mysql.commit ()
print "Successfully Saved Data"
if row [0] == row [0]:
kill = "KILL" + str (row [0])
cur.execute
connection_mysql.commit ()
print "Deleted data"
As you consult and save in MySQL, I want to continue browsing in MySQL but save the data in SQL Server.
I would appreciate the help :)