prashantsengar / TimeTracker

Basic Time tracker built with Python. Track what applications you spend your most time on.
16 stars 12 forks source link

Adarshs169 patch 1 #3

Closed Adarshs169 closed 4 years ago

Adarshs169 commented 4 years ago

I have implemented weekly and monthly reports enhancements using sqlite3 and datetime library.

prashantsengar commented 4 years ago

@Adarshs169 did you test out the report option in your PC? Because when I click on either Weekly report or Monthly report, I get an error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Prashant\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)
  File "P:\Projects\TimeTracker\Test\track.py", line 34, in <lambda>
    command=lambda:self.stop_recording())
  File "P:\Projects\TimeTracker\Test\track.py", line 91, in stop_recording
    self.save_datanew()
  File "P:\Projects\TimeTracker\Test\track.py", line 143, in save_datanew
    cursor.execute('''select date from info''')
sqlite3.OperationalError: no such table: info
today month and year 12 2019
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Prashant\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)
  File "P:\Projects\TimeTracker\Test\track.py", line 42, in <lambda>
    command=lambda:self.month_report())
  File "P:\Projects\TimeTracker\Test\track.py", line 170, in month_report
    cursor.execute('''select name,time from info where strftime('%m',date)=? and strftime('%Y',date)=?''',(today_month,today_year))
sqlite3.OperationalError: no such table: info

I would recommend you import traceback and add a line below logging.warning traceback.print_exc() to get the complete traceback of the error.

Know more about traceback

Adarshs169 commented 4 years ago

Actually there is a line in savedatanew() method which is commented. You need to execute that line once so that the database gets created otherwise without the info table, it won't work. Copy that line of code and execute that once, afterwards it will work for sure,

Adarshs169 commented 4 years ago

I think the database file is not present in the folder where the .py file is present in the system. That's why, it is not identifying the SQL table and giving an error. It is working fine in my PC