1. 설치

 

    yum install mysqldb



2. fetchone


   import MySQLdb

   mydb = MySQLdb.connect(host = 'localhost', user = 'test', passwd = 'test', db = 'test')

   cur = mydb.cursor()

   statement = "SELECT * FROM test1 WHERE name='a1'"

   cur.execute(statement)

   result = cur.fetchone()

   print result



3. fetchmany

   import MySQLdb

   mydb = MySQLdb.connect(host = 'localhost', user = 'test', passwd = 'test', db = 'test')

   cur = mydb.cursor()

   statement = "SELECT * FROM test1 WHERE name='a1'"

   cur.execute(statement)

   results = cur.fetchmany(10)

   for result in results:

      print result


   cur.execute("SHOW TABLES")

   time.sleep(20)

   print cur.fetchmany(10)

   time.sleep(20)

   print cur.fetchmany(10)

'RDB > MySQL' 카테고리의 다른 글

Orchestrator  (0) 2017.11.17
mysql maridb 10.2 install  (0) 2017.11.09
mysql5.7 install  (0) 2016.10.29
Performance 설정  (0) 2016.08.10
mysql status중 handler  (0) 2016.08.10

+ Recent posts