code: def _create_table(db, table_name, columns, overwrite=False):
      
      with contextlib.closing(db.cursor()) as c:
          table_exists = c.execute((
              u'SELECT EXISTS(SELECT 1 FROM sqlite_master'
              u' WHERE type="table" and name=?) as "exists"'
          ), (table_name,)).fetchone()
  
          if table_exists['exists']:
              if not overwrite:
                  raise TableExists()
  
              c.execute(u'DROP TABLE IF EXISTS "{table_name}"'.format(
                  table_name=table_name
              ))
  
          # Create the table if it doesn't already exist.
          c.execute((
              u'CREATE TABLE IF NOT EXISTS "{table_name}"'
              u'(id INTEGER PRIMARY KEY AUTOINCREMENT);'
          ).format(table_name=table_name))
  
          # Cache the columns that are already there so we create only
          # those that are missing.
          c.execute(u'PRAGMA table_info("{table_name}");'.format(
              table_name=table_name
          ))
  
          results = c.fetchall()
          existing_columns = set(r['name'] for r in results)
  
          for header in columns:
              if header in existing_columns:
                  continue
  
              # In SQLite3, new columns can only be appended.
              c.execute((
                  u'ALTER TABLE "{table_name}"'
                  u' ADD COLUMN "{col}" TEXT;'
              ).format(
                  table_name=table_name,
                  col=header
              ))
  
          # Typically, table modifications occur outside of a
          # transaction so this is just a precaution.
          db.commit()
docs: Create's `table_name` in `db` if it does not already exist,
      and adds any missing columns.
  
      :param db: An active SQLite3 Connection.
      :param table_name: The (unicode) name of the table to setup.
      :param columns: An iterable of column names to ensure exist.
      :param overwrite: If ``True`` and the table already exists,
                        overwrite it.