O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Conversation class

Inside your server folder (not the new conversations folder), create a file named conversation.py. This will hold a class of the same name, which handles the sqlite side of creating and interacting with these databases:

import sqlite3class Conversation:    def __init__(self, database):        self.database = database

This looks much like the __init__ method of our Database class, but it will have its SQLite database filename passed to it, allowing this class to work with multiple different conversation databases.

The first method we will need to write is one that will create the table inside the database:

def initialise_table(self):    sql = "CREATE TABLE conversation (author text, message text, date_sent text)" conn = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required