0

I am trying to parse the data out from an SQLite DB file table called sms and it is working but when the date and time is displayed it is not readable, it is just a string of numbers.

How can I display the date and time in a readable format on display to the console?

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


# 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()
GreenCoder90
  • 353
  • 3
  • 7
  • 21

0 Answers0