samedi 6 février 2016

Converting only time from an SQL query in python3

I am currently analysing a database using an SQL query within python3. From performing a command within an SQL interpreter, it is possible to convert the vales given to a time format as yyyy:mm:dd hh:mm:ss using

datetime(date + strftime('%s','2001-01-01'), 'unixeopch').

This gives the correct converted filetime. However, when attempting to do this in Python, this does not work. It is using the chat.db database with date starting from 2001-01-01. Any help in how to fix this would be greatly appreciated!

The function attempting to be called is as follows:

import datetime import time from time import strftime

def read_messages():

 c.execute('SELECT message.text, handle.id, datetime(message."date" + strftime('%s','2001-01-01'). 'unixepoch') cache_roomnames, is_from_me FROM message, handle WHERE date > 475790679')
 for row in c.fetchall():
 print(row, c.fetchall())

Aucun commentaire:

Enregistrer un commentaire