DmitrMakeev commited on
Commit
4c58695
1 Parent(s): ac27597

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -1862,11 +1862,30 @@ def from_shop_st():
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)
@@ -1927,8 +1946,6 @@ def from_shop_st():
1927
 
1928
 
1929
 
1930
-
1931
-
1932
 
1933
 
1934
 
 
1862
  shop_st_json = json.dumps(shop_st_data)
1863
 
1864
  if result:
1865
+ update_columns = []
1866
+ update_values = []
1867
+
1868
+ if name:
1869
+ update_columns.append('name = ?')
1870
+ update_values.append(name)
1871
+ if phone:
1872
+ update_columns.append('phone = ?')
1873
+ update_values.append(phone)
1874
+ if email:
1875
+ update_columns.append('email = ?')
1876
+ update_values.append(email)
1877
+
1878
+ update_columns.append('shop_st = ?')
1879
+ update_values.append(shop_st_json)
1880
+
1881
+ update_values.extend([email, phone])
1882
+
1883
+ query = f"""
1884
  UPDATE contacts
1885
+ SET {', '.join(update_columns)}
1886
+ WHERE email = ? OR phone = ?
1887
+ """
1888
+ cursor.execute(query, update_values)
1889
  else:
1890
  cursor.execute("""
1891
  INSERT INTO contacts (name, phone, email, shop_st)
 
1946
 
1947
 
1948
 
 
 
1949
 
1950
 
1951