• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Parsing Date from SQLite DB Table

I have a Python script that parses data from the sms table of the mmssms.db database file of an Android phone running 5.1.

At the moment, the script is parsing out the date in a string of numbers.

How can I parse it out as a human readable date so it can be interpreted correctly?



# My Code

# Script that parses data from the sms table contained in the mmssms database (text message database)

# import statements
import sqlite3, datetime
from sqlite3 import Error
import datetime
import time

# create a database connection to the SQLite database specified by the db_file
def create_connection(db_file):
try:
conn = sqlite3.connect(db_file)
return conn
except Error as e:
print(e)

return None

# Query specific rows in the sms table
def select_data(conn):

cur = conn.cursor()
cur.execute("SELECT _id, date, date_sent, read, type, body, seen FROM sms")
print("Outputting the contents of the sms table within the mmssms.db database file")
print("\t")
rows = cur.fetchall()
for row in rows:

print(row)

# path to where the db files are stored
def main():
database = "H:\College Fourth Year\Development Project\Final Year Project 2018\mmssms.db"

# create a database connection
conn = create_connection(database)
with conn:

# print("Query specific columns")
select_data(conn)
# close db connection
if(conn):
conn.close()
print("Database closed")


if __name__ == '__main__':
main()
 
Back
Top Bottom