Sep-26-2017, 12:24 AM
Hello, I am totally new to python.
I am learning to use pymysql to retrive daa from mysql, I have this code:
I am learning to use pymysql to retrive daa from mysql, I have this code:
#!/usr/bin/python3
import pymysql
#make a connection to mysql
conn = pymysql.connect(
host='localhost',
user='xyz',
passwd='abcde',
db='my_db',
autocommit=True
)
cur=conn.cursor()
sql="SELECT col_2 FROM my_tb WHERE row_id=1"
print(cur.execute(sql))How do I print out the data in col_2? Thanks.
