Skip to content

Instantly share code, notes, and snippets.

@zikrach
Created January 4, 2014 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zikrach/8261098 to your computer and use it in GitHub Desktop.
Save zikrach/8261098 to your computer and use it in GitHub Desktop.
cteate table sqlite3
@classmethod
def create_table(self):
# TODO 1. Автоматично формувати SQL-команду створення таблиці
print("Creating document table")
path = os.path.expanduser(
"~/python/virtualenv/python3/virt_Python3/home/data.db")
try:
connection = sqlite3.connect(path)
cursor = connection.cursor()
cursor.execute(
"""
create table t_document(
i_id integer not null primary key autoincrement,
f_status integer null
);
"""
)
connection.commit()
connection.close()
print("Database creating success")
except sqlite3.OperationalError as Exc:
print("Database already exists. ", *Exc.args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment