我已经将我的MySQL数据库与PyMySQL作为连接器相连,并且执行得很好,但是每当我尝试执行或运行SQLHandler sql = new SQLHandler()
List<GroovyRowResult> res = sql.getSelectResults('SELECT COUNT(*) as calls FROM test WHERE canc IS NOT NULL AND cncat IS NULL')
int countFromDb = res.get(0).get('Calls')
println("No. of rows in Database is(are):" + res.get(0))
时,它仅返回一个整数值作为输出。
代码:
cursor.execute("some statement ")
输出:
import pymysql
db=
pymysql.connect(host='localhost',port=3306,user='root',passwd='')
c = db.cursor()
c.execute("show databases;")
c.execute("use tracer;") #my database name
c.execute("select * from stud;")
我希望输出作为某些数据库的名称,但是它仅提供c.execute("show databases;")
作为输出。
7
我期望输出作为元组中的数据,但是我收到的输出是
c.execute("select * from stud;")
,即行数。