Results 1 to 6 of 6

Thread: QSqlQuery in PyQt4

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question QSqlQuery in PyQt4

    What different QSqlQuery in Qt and PyQt ?

    Qt Code:
    1. query=QSqlQuery()
    2. query.prepare("select id, nama, id_group, groups from pemakai where nick=:a and groups=:b")
    3. query.bindValue(":a", self._username)
    4. query.bindValue(":b", self._grp)
    5. if query.exec_():
    6. print "OK"
    7. else:
    8. print query.lastError().text()
    To copy to clipboard, switch view to plain text mode 

    Result:

    ERROR: wrong number of parameters for prepared statement "qpsqlpstmt_1"
    DETAIL: Expected 2 parameters but got 0.
    QPSQL: Unable to create query

  2. #2
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSqlQuery in PyQt4

    You QSqlQuery should be related to open database connection, right?
    -- Tanuki

    per cauda vel vaculus cauda

  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: QSqlQuery in PyQt4

    Exactly. And I did

  4. #4
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSqlQuery in PyQt4

    Then it should be something like: query=QSqlQuery(mydb)
    -- Tanuki

    per cauda vel vaculus cauda

  5. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: QSqlQuery in PyQt4

    I use one database (as default database). So not must use parameter in QSqlQuery

  6. #6
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlQuery in PyQt4

    And what happens if you provide a hard-coded name instead of
    self._username
    Just to make sure the problem is really in the bindValue mechanism.

Similar Threads

  1. Replies: 6
    Last Post: 26th April 2010, 17:47
  2. Replies: 1
    Last Post: 20th May 2009, 21:36
  3. Extracting QSqlQuery results in PyQt4
    By amicitas in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2008, 06:10
  4. PyQt4 to Py3exe problem
    By WinchellChung in forum Newbie
    Replies: 3
    Last Post: 9th August 2007, 20:33
  5. Problems with QSqlQuery update
    By whoops.slo in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2006, 08:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.