2016-05-12 8 views
0

holen Wie kann ich mehr Daten nach select Finish (EOF) zeigen aber mehr Daten einfügen:Mysql Python eof dann zurück nach mehr Daten

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 

Antwort

0

Nur:

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") 

execute erneut die Abfrage holen Sie mehr Daten. So was;

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) 
Verwandte Themen