Some changes
This commit is contained in:
parent
fb62cb9aab
commit
45d22be777
|
@ -7,6 +7,8 @@
|
|||
# для чтения данных напрямую с com-порта АТС
|
||||
# > python data_reader.py -port /dev/ttyUSB0
|
||||
#
|
||||
# Автор: Сергей Калинин banzaj28@gmail.com
|
||||
# Лицензия: GPL
|
||||
#########################################################
|
||||
|
||||
import pymysql
|
||||
|
@ -22,10 +24,11 @@ def insert(**kwargs):
|
|||
"""Вставка данных в БД. В качестве параметров список полей и значений"""
|
||||
qwery = 'INSERT INTO `cdr` ('
|
||||
for key in kwargs.keys():
|
||||
qwery = qwery + '`' + key +'`, '
|
||||
qwery = "{} `{}`, ".format(qwery,key)
|
||||
qwery = qwery.rstrip(', ') + ') VALUES('
|
||||
for key in kwargs.keys():
|
||||
qwery = qwery + '"' + kwargs.get(key) +'", '
|
||||
#qwery = qwery + '"' + kwargs.get(key) +'", '
|
||||
qwery = "{} '{}',".format(qwery,kwargs.get(key))
|
||||
|
||||
qwery = qwery.rstrip(', ') + ');'
|
||||
print(qwery)
|
||||
|
@ -46,8 +49,8 @@ def parce_string(line):
|
|||
|
||||
# Разбор строки
|
||||
# Преобразуем дату к виду "ДД/ММ/ГГГГ"
|
||||
call_date = line[:2] + "." + line[3:5] + ".20" + line[6:8]
|
||||
call_date = "20" + line[6:8] + "/" + line[3:5] + "/" + line[:2]
|
||||
#call_date = "{}.{}.20{}".format(line[:2],line[3:5],line[6:8])
|
||||
call_date = "20{}/{}/{}".format(line[6:8],line[3:5],line[:2])
|
||||
call_time = line[9:14].strip()
|
||||
int_number = line[19:22].strip()
|
||||
ext_co_line = line[23:25].strip()
|
||||
|
|
Loading…
Reference in New Issue
Block a user