Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

sqlite - Python sqlite3 how to pull 100 rows in "quality" column and then change the value of them

So I have data and I have a quality column for it. All data starts out with a quality of 1. I want to pull the data and print the 100 rows then change their quality to 2, then 3, then I'm moving them to a new table. I need help with changing and printing their values first.

'''

def pull(self,table,quality):
    conn = sqlite3.connect('Emaildatabase.db')
    c = conn.cursor()

    if table == 'Emails':
        c.execute('SELECT * FROM Emails WHERE Quality=(?) LIMIT 100',(quality,))

        data = c.fetchall()
        print(data)
        for row in data:
            print(row)

        if quality == 1:
            c.execute('UPDATE Emails SET Quality=2 WHERE Quality=1')
            conn.commit()
        if quality == 2:
            c.execute('UPDATE Emails SET Quality=3 WHERE Quality=2')
            conn.commit()
        if quality == 3:
            c.execute('UPDATE Emails SET Quality=4 WHERE Quality=3')
            conn.commit()
        

'''

this is what i have so far. when it pulls the data it changes the quality of every value and im not sure where to go from here in terms of making it only change 100 rows per pull.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...