I need to print a date in SQLite like this “24-03-2011 10:45:00”, for now I only can print the date.
>>> import sqlite3
>>> database = sqlite3.connect('basedadosteste.db')
>>> cursor = database.cursor()
>>> cursor.execute("SELECT date('now');")
<sqlite3.Cursor object at 0x00BC0710>
>>> results = cursor.fetchall()
>>> for entry in results:
... print entry
...
(u'2011-03-25',)
>>>
Can someone give me a clue on how to do this?
Best Regards,
dateonly gives you the date, hence the name. If you want the date and time, you have to usedatetime.And if you want to format the date, you can use
strftime– either in the SQL command, or in Python. See the sqlite3 date docs.This would work: