选择完成后如何显示更多数据(eof)但插入更多数据:

import MySQLdb
import MySQLdb.cursors
cnx = MySQLdb.connect(user="user",
             passwd="password",
             db="mydb",
             cursorclass = MySQLdb.cursors.SSCursor
            )
cursor = cnx.cursor()
cursor.execute("SELECT * FROM individual_data")
while FOREVER:
    row = cursor.fetchone()
    if row is not None:
        print row

最佳答案

只是:

cursor.execute("SELECT * FROM individual_data where " +
             "datetimestamp >= TIMESTAMP '" + str(TOP_DT1) + "' and datetimestamp < TIMESTAMP '" + str(TOP_DT11) + "' order by datetimestamp, segment_id, user_id, id")


再次执行查询以获取更多数据。像这样;

    row1 = fetch_one(cur1)
    while row1 is not None:
        b = read_individual_data(row1)
        row = emit_individual_data(a, b)
        TOP_DT1 = TOP_DT11
        row1 = fetch_one(cur1)

08-20 03:44