DmitrMakeev
commited on
Commit
•
473e095
1
Parent(s):
290296c
Create my_sqlite.py
Browse files- my_sqlite.py +47 -0
my_sqlite.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sqlite3
|
2 |
+
|
3 |
+
|
4 |
+
from flask import request, jsonify
|
5 |
+
import globs
|
6 |
+
import os
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
def create_db():
|
12 |
+
# Создание подключения к базе данных SQLite
|
13 |
+
conn = sqlite3.connect('mydatabase.db')
|
14 |
+
cur = conn.cursor()
|
15 |
+
|
16 |
+
# Создание таблицы с автоинкрементным столбцом
|
17 |
+
cur.execute('''
|
18 |
+
CREATE TABLE IF NOT EXISTS my_table (
|
19 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
20 |
+
column1 TEXT,
|
21 |
+
column2 TEXT,
|
22 |
+
column3 TEXT,
|
23 |
+
column4 TEXT,
|
24 |
+
column5 TEXT,
|
25 |
+
column6 TEXT,
|
26 |
+
column7 TEXT,
|
27 |
+
column8 TEXT,
|
28 |
+
column9 TEXT,
|
29 |
+
column10 TEXT
|
30 |
+
)
|
31 |
+
''')
|
32 |
+
|
33 |
+
# Применение изменений и закрытие соединения
|
34 |
+
conn.commit()
|
35 |
+
cur.close()
|
36 |
+
conn.close()
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|