From dogan, 6 Months ago, written in Python.
This paste is a reply to format string from dogan
- view diff
Embed
  1. import sqlite3
  2.  
  3. class Db:
  4.  
  5.     def __init__(self, name):
  6.         self.name = name if isinstance(name, str) and name.endswith('.db') else str(name) + '.db'
  7.         self.connection = sqlite3.connect(self.name)
  8.         self.cursor = self.connection.cursor()
  9.  
  10.     def create_table(self, table_name, *args):
  11.         self.cursor.execute('''
  12.        CREATE TABLE IF NOT EXISTS {}(
  13.        {}
  14.        )
  15.        '''.format(table_name, (len(vars)*'{}, ').format(*args)))
  16.         self.connection.commit()