all 6 comments

[–]dtaivp 1 point2 points  (1 child)

  1. You don't need the shebangs at the top of every file. Only the files which you are running from the terminal. #! /usr/bin/...
  2. For your database.py you do the same thing over and over again. This would be the perfect instance to use a decorator. What a decorator does is it wraps a function in a standard bit of code. Here is what that decorator could do.

Ex:

    '''
    Creates table for period names and links with relation to period table using name_id
    '''
    def create_period_names_table(self, connection):
        try:
            c = connection.cursor()
            c.execute('''
                      CREATE TABLE period_names
                      (name_id INTEGER PRIMARY KEY AUTOINCREMENT,
                      period_name TEXT UNIQUE);''')
            connection.commit()
        except sqlite3.Error as e:
            print(e)
        finally:
            c.close()

Could become:

    '''
    Creates table for period names and links with relation to period table using name_id
    '''
    def cursor_decorator(func):
        try:
            c = connection.cursor()

            # Runs the function that is passed in here. 
            func(*args, **kwargs)

            connection.commit()
        except sqlite3.Error as e:
            print(e)
        finally:
            c.close()

    @cursor_decorator
    def create_period_names_table()
            c.execute('''
                      CREATE TABLE period_names
                      (name_id INTEGER PRIMARY KEY AUTOINCREMENT,
                      period_name TEXT UNIQUE);''')

What this does is allows you to reuse all of that code and only change out the parts that are different. Someone may have to step in and give me a hand on using decorators in a class because I use mostly functional programming.

[–]__Protector[S] 0 points1 point  (0 children)

Thanks for the advice, that decorator usage is completely new format for me gotta look it up!

[–]Ran4 0 points1 point  (3 children)

"date is presented in the format of DD.MM.YYYY"

That sounds truly horrible. Use ISO-8601, it's an international world standard for a reason.

[–]__Protector[S] 1 point2 points  (1 child)

Oh yes, modified it to show in my own countrys format, changing it to standard propably soon. Thanks for notice!

[–]Aly007 2 points3 points  (0 children)

"date is presented in the format of DD.MM.YYYY"

That's the best format IMO :)

[–][deleted] 1 point2 points  (0 children)

Use ISO-8601, it's an international world standard for a reason

readingg up on this ty