Page MenuHomec4science

ConnectionMySQL.py
No OneTemporary

File Metadata

Created
Tue, May 28, 23:32

ConnectionMySQL.py

import tensorflow as tf
import mysql.connector
from mysql.connector import Error
try:
mySQLconnection = mysql.connector.connect(host='localhost',
database='newschema',
user='root',
password='stella0712')
sql_select_Query = "SELECT * from results"
cursor = mySQLconnection .cursor()
cursor.execute(sql_select_Query)
records = cursor.fetchall()
print("Total number of rows in newschema is - ", cursor.rowcount)
print ("Printing each row's column values i.e. schema record")
for row in records:
print("Id = ", row[0], )
print("SvO2 = ", row[1])
print("pam = ", row[2])
print("pp = ", row[3], "\n")
cursor.close()
print("\n")
print(records, "\n")
print(type(records), "\n")
dataset = tf.convert_to_tensor(records)
print(dataset);
except Error as e:
print("Error while connecting to MySQL", e)
finally:
#closing database connection.
if mySQLconnection .is_connected():
mySQLconnection.close()
print("MySQL connection is closed")

Event Timeline