Created
January 4, 2014 21:42
-
-
Save zikrach/8261098 to your computer and use it in GitHub Desktop.
cteate table sqlite3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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