Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F64721370
ConnectionMySQL.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, May 28, 23:32
Size
1 KB
Mime Type
text/x-python
Expires
Thu, May 30, 23:32 (2 d)
Engine
blob
Format
Raw Data
Handle
17949769
Attached To
rMLECMO Machine Learning ECMO
ConnectionMySQL.py
View Options
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
Log In to Comment