1

is not there any way to store python dates or pyqt4 dates (QDate) in sqlite3 ? I'd not like to use sqlite's date types since i'll need to find the difference between dates that i'll store.That's what i'm trying :

    record = QtCore.QDate.currentDate()
    latest = self.calendar.selectedDate()

    db = sql.connect(":memory:")
    cur = self.db.cursor()
    cur.execute("CREATE TABLE  invoices(record, latest)")
    cur.execute("INSERT INTO invoices VALUES (?, ?)", (record, latest)) 
    db.commit()

That's the error : sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type. Thanks in advance.

1
  • You can always pickle your object and store it as BLOB in your DB, although that might be overkill depending on your needs... docs.python.org/library/pickle.html Commented Jul 8, 2011 at 10:32

2 Answers 2

3

No. Convert it to a timestamp first.

Sign up to request clarification or add additional context in comments.

2 Comments

Or use adapters and converters or, I don't know QT and how it interacts with python types, use the datetime module: docs.python.org/library/…
I tried storing it as timestamp but it also did not work but that link will solve it, i guess, thanks.docs.python.org/library/…
0

I tried many methods and most straightforward is convert it to timestamp, then when retrieve it back convert from timestamp to date and that's best solution because if you store it like string object it will be impossible to do logic operations on your data but with timestamp its simple...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.