jeudi 14 juillet 2016

Fetch the data from rows with limit

I'm fetching the list of full data from a sqlite3 database. I want to pull 20 rows of data for each channel, but on my code it will fetch all of data for each channel.

Here is the code:

#get the programs list
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', 'source.db'))
conn = database.connect(profilePath)
cur = conn.cursor()
cur.execute('SELECT channel, title, start_date, stop_date FROM programs where channel=?', [channel])
programList = list()
programs = cur.fetchall()

start_pos = 375    # indent for first program

for ind, row in enumerate(programs):
   title = row[1]

Can you please show me how I could fetch 20 rows of data from a database without fetching all of the data for each channel??

Aucun commentaire:

Enregistrer un commentaire