def create_schema(self):
        try:
            conn = self.get_conn()
            cur = conn.cursor()
            cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?", (self.table_name,))
            if cur.fetchone() is None:
                logging.debug("Initializing schema for {0}".format(self.table_name))
                columns = []
                for col, dbtype in self.schema.items():
                    pkey = ""
                    if hasattr(self, 'primary_key') and col == self.primary_key:
                        pkey = "PRIMARY KEY"

                    columns.append("{0} {1} {2}".format(col, dbtype.value, pkey))

                sql = "CREATE TABLE {0}( {1} );".format(self.table_name, ", ".join(columns))
                logging.debug(sql)
                conn.execute(sql)
        except sqlite3.Error as e:
            logging.error("Error creating table for {0}: {1}".format(self.table_name, e.args[0]))
        finally:
            cur.close()
dataset/ETHPy150Open datamachine/telex/telex/DatabaseMixin.py/DatabaseMixin.create_schema/original