본문 바로가기
MySql

MySQL Python 용 MySQLDB API에서 num_rows () 함수를 어떻게 사용합니까?

by 베이스 공부 2020. 11. 4.
반응형

이 진술이 있습니다

cursor = connection.cursor()
query = "SELECT * from table"
cursor.execute(query)
res = cursor.fetchall()

 

해결 방법

 

cursor = connection.cursor()
query = "SELECT * from table"
cursor.execute(query)
print cursor.rowcount


찾고있는 num_rows () 함수가 MySQLdb 모듈에 없습니다. num_rows 메소드가있는 result 클래스를 포함하는 _mysql 이라는 내부 모듈이 있지만 사용해서는 안됩니다. _mysql 의 구현 세부 사항으로 간주됩니다.

 

참조 페이지 https://stackoverflow.com/questions/3890517

 

 

반응형

댓글