Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide / SQLite3 - need duplicate code to parse query.first() then while query.next() ???
QtWS25 Last Chance

PySide / SQLite3 - need duplicate code to parse query.first() then while query.next() ???

Scheduled Pinned Locked Moved Language Bindings
2 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alabaster
    wrote on last edited by
    #1

    I assume this is a very basic database question but I'm still fairly new to database queries...

    When executing a QSqlQuery, is it necessary to process the first row separately from subsequent rows? This is the way that I've been doing it:

    @
    query = QSqlQuery("SELECT Blahblah, Blippity, Bloop FROM Floozle ORDER BY Bloop")

    query.first()
    codeToParseRecord() #If I leave this out it skips the first record

    while query.next():
    codeToParseRecord()
    @

    Is this the best way to do it or am I missing something? It just seems wrong to have to duplicate code every time I execute a query.

    Thanks

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi,
      you do not need the lines
      @
      query.first()
      codeToParseRecord()
      @

      simply start with query.exec():

      @
      query = QSqlQuery("SELECT Blahblah, Blippity, Bloop FROM Floozle ORDER BY Bloop")

      if (query.exec()) {
      while query.next():
      codeToParseRecord()
      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved