DmitrMakeev commited on
Commit
c803751
1 Parent(s): 4412515

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -11
app.py CHANGED
@@ -1920,6 +1920,51 @@ def from_shop_st2():
1920
 
1921
 
1922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1923
  # Маршрут для приема GET запроса
1924
  @app.route('/order3', methods=['GET'])
1925
  def from_shop_st3():
@@ -1978,18 +2023,9 @@ def from_shop_st3():
1978
 
1979
  conn.commit()
1980
 
1981
- # Дополнительный проход для замены NULL на пустые строки
1982
- cursor.execute("""
1983
- UPDATE contacts
1984
- SET name = COALESCE(name, ''),
1985
- phone = COALESCE(phone, ''),
1986
- email = COALESCE(email, ''),
1987
- shop_st = COALESCE(shop_st, ''),
1988
- n_con = COALESCE(n_con, '')
1989
- WHERE email = ? OR phone = ?
1990
- """, (email, phone))
1991
 
1992
- conn.commit()
1993
  conn.close()
1994
 
1995
  return json.dumps(shop_st_data), 200
 
1920
 
1921
 
1922
 
1923
+ # Функция для замены NULL на пустые строки
1924
+ def replace_null_with_empty_string(conn):
1925
+ cursor = conn.cursor()
1926
+ query = """
1927
+ UPDATE contacts
1928
+ SET
1929
+ name = COALESCE(name, ''),
1930
+ phone = COALESCE(phone, ''),
1931
+ email = COALESCE(email, ''),
1932
+ vk_id = COALESCE(vk_id, ''),
1933
+ chat_id = COALESCE(chat_id, ''),
1934
+ ws_st = COALESCE(ws_st, ''),
1935
+ ws_stop = COALESCE(ws_stop, ''),
1936
+ web_st = COALESCE(web_st, ''),
1937
+ fin_prog = COALESCE(fin_prog, ''),
1938
+ b_city = COALESCE(b_city, ''),
1939
+ b_fin = COALESCE(b_fin, ''),
1940
+ b_ban = COALESCE(b_ban, ''),
1941
+ b_ign = COALESCE(b_ign, ''),
1942
+ b_baners = COALESCE(b_baners, ''),
1943
+ b_butt = COALESCE(b_butt, ''),
1944
+ b_mess = COALESCE(b_mess, ''),
1945
+ shop_st = COALESCE(shop_st, ''),
1946
+ curator = COALESCE(curator, ''),
1947
+ pr1 = COALESCE(pr1, ''),
1948
+ pr2 = COALESCE(pr2, ''),
1949
+ pr3 = COALESCE(pr3, ''),
1950
+ pr4 = COALESCE(pr4, ''),
1951
+ pr5 = COALESCE(pr5, ''),
1952
+ gc_url = COALESCE(gc_url, ''),
1953
+ key_pr = COALESCE(key_pr, ''),
1954
+ n_con = COALESCE(n_con, ''),
1955
+ canal = COALESCE(canal, ''),
1956
+ data_on = COALESCE(data_on, ''),
1957
+ data_t = COALESCE(data_t, ''),
1958
+ utm_source = COALESCE(utm_source, ''),
1959
+ utm_medium = COALESCE(utm_medium, ''),
1960
+ utm_campaign = COALESCE(utm_campaign, ''),
1961
+ utm_term = COALESCE(utm_term, ''),
1962
+ utm_content = COALESCE(utm_content, ''),
1963
+ gcpc = COALESCE(gcpc, '')
1964
+ """
1965
+ cursor.execute(query)
1966
+ conn.commit()
1967
+
1968
  # Маршрут для приема GET запроса
1969
  @app.route('/order3', methods=['GET'])
1970
  def from_shop_st3():
 
2023
 
2024
  conn.commit()
2025
 
2026
+ # Замена NULL на пустые строки
2027
+ replace_null_with_empty_string(conn)
 
 
 
 
 
 
 
 
2028
 
 
2029
  conn.close()
2030
 
2031
  return json.dumps(shop_st_data), 200