Alt+Tab
and get into - correctly, in the console with the Python 2.7.5+
and the inviting prompt >>>
#!/usr/bin/python import MySQLdb as mysql con = mysql.connect('localhost', 'mobile', 'mobile', 'mobile') cur = con.cursor() with open('calls.log') as f: for line in f: if 'MOC' in line: tokens = line.split() if len(tokens) == 11: cur.execute("INSERT INTO calls (operator, amount) VALUES('" + tokens[1] + "','" + tokens[6] + "')") con.commit()
cur.execute("SELECT operator,plan,call_init,first_min_int,first_min_ext,min_int,min_ext FROM tariffs") rows = cur.fetchall() for row in rows: operator, plan, call_init, first_min_int, first_min_ext, min_int, min_ext = row # cur.execute("SELECT COUNT(*) FROM calls") total = call_init*cur.fetchone()[0] # cur.execute("SELECT COALESCE(SUM(LEAST(amount,60)),0) FROM calls WHERE operator='" + operator + "'") total += cur.fetchone()[0]/60*first_min_int # , cur.execute("SELECT COALESCE(SUM(amount-60),0) FROM calls WHERE operator='" + operator + "' AND amount > 60") total += cur.fetchone()[0]/60*min_int # cur.execute("SELECT COALESCE(SUM(LEAST(amount,60)),0) FROM calls WHERE operator<>'" + operator + "'") total += cur.fetchone()[0]/60*first_min_ext # , cur.execute("SELECT COALESCE(SUM(amount-60),0) FROM calls WHERE operator<>'" + operator + "' AND amount > 60") total += cur.fetchone()[0]/60*min_ext print plan + " : " + str(round(total/100, 2)) + " .."
Magti Standard : 47.1 ye Magti I Alternative : 56.5 ye Bani Standard : 29.72 ye Bani Zero+ : 26.67 ye Geocell 000 : 49.94 ye Geocell 1-10 : 35.86 ye Geocell 12 : 35.66 ye Beeline 007 : 37.69 ye Beeline Non Stop : 40.7 ye Bani Universal : 39.21 ye
Source: https://habr.com/ru/post/211490/
All Articles