Browse Source

Правки по заказам #21

Переделка получения ID после вставки на старую версию sqlite
master
parent
commit
8eddb51e05
  1. 7
      bot_modules/mod_table_operate.py

7
bot_modules/mod_table_operate.py

@ -340,7 +340,7 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
values += ['?']
param += (a_ItemData[n], )
request = f'INSERT INTO {table_name}({",".join(fields)}) VALUES({",".join(values)}) RETURNING {key_field}'
request = f'INSERT INTO {table_name}({",".join(fields)}) VALUES({",".join(values)})' # RETURNING {key_field}
#print('request', request, param)
res, error = self.m_Bot.SQLRequest(request, commit = True, return_error = True, param = param)
@ -350,9 +350,10 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
else:
self.m_Log.Success(f'Пользователь {a_UserID}. Добавлена запись в таблицу {request} {param}.')
res_id, error_id = self.m_Bot.SQLRequest(f'SELECT rowid from {table_name} order by ROWID DESC limit 1', commit = False, return_error = True)
table_item_id = -1
if not error and res and len(res) == 1 and len(res[0]) == 1:
table_item_id = str(res[0][0])
if not error_id and res_id and len(res_id) == 1 and len(res_id[0]) == 1:
table_item_id = str(res_id[0][0])
#print('res_id', res, error, table_item_id)
subscribe_type = bot_subscribes.SubscribeType.ANY_ITEM_ADD

Loading…
Cancel
Save