DmitrMakeev
commited on
Commit
•
ac27597
1
Parent(s):
209661f
Update app.py
Browse files
app.py
CHANGED
@@ -1843,13 +1843,15 @@ def from_shop_st():
|
|
1843 |
conn = sqlite3.connect(DATABASE6)
|
1844 |
cursor = conn.cursor()
|
1845 |
|
1846 |
-
cursor.execute("SELECT shop_st FROM contacts WHERE email = ? OR phone = ?", (email, phone))
|
1847 |
result = cursor.fetchone()
|
1848 |
|
1849 |
if result:
|
1850 |
-
shop_st = result
|
|
|
1851 |
shop_st_data = json.loads(shop_st)
|
1852 |
else:
|
|
|
1853 |
shop_st_data = {}
|
1854 |
|
1855 |
if del_flag == '1':
|
@@ -1860,9 +1862,16 @@ def from_shop_st():
|
|
1860 |
shop_st_json = json.dumps(shop_st_data)
|
1861 |
|
1862 |
if result:
|
1863 |
-
cursor.execute("
|
|
|
|
|
|
|
|
|
1864 |
else:
|
1865 |
-
cursor.execute("
|
|
|
|
|
|
|
1866 |
|
1867 |
conn.commit()
|
1868 |
conn.close()
|
|
|
1843 |
conn = sqlite3.connect(DATABASE6)
|
1844 |
cursor = conn.cursor()
|
1845 |
|
1846 |
+
cursor.execute("SELECT name, phone, email, shop_st FROM contacts WHERE email = ? OR phone = ?", (email, phone))
|
1847 |
result = cursor.fetchone()
|
1848 |
|
1849 |
if result:
|
1850 |
+
name_db, phone_db, email_db, shop_st = result
|
1851 |
+
shop_st = shop_st if shop_st else '{}'
|
1852 |
shop_st_data = json.loads(shop_st)
|
1853 |
else:
|
1854 |
+
name_db, phone_db, email_db = name, phone, email
|
1855 |
shop_st_data = {}
|
1856 |
|
1857 |
if del_flag == '1':
|
|
|
1862 |
shop_st_json = json.dumps(shop_st_data)
|
1863 |
|
1864 |
if result:
|
1865 |
+
cursor.execute("""
|
1866 |
+
UPDATE contacts
|
1867 |
+
SET name = ?, phone = ?, email = ?, shop_st = ?
|
1868 |
+
WHERE email = ? OR phone = ?""",
|
1869 |
+
(name or name_db, phone or phone_db, email or email_db, shop_st_json, email, phone))
|
1870 |
else:
|
1871 |
+
cursor.execute("""
|
1872 |
+
INSERT INTO contacts (name, phone, email, shop_st)
|
1873 |
+
VALUES (?, ?, ?, ?)""",
|
1874 |
+
(name_db, phone_db, email_db, shop_st_json))
|
1875 |
|
1876 |
conn.commit()
|
1877 |
conn.close()
|