Commit a56171cd by Javier

Versión 1.0

parent 640e0a1c
......@@ -510,6 +510,7 @@ def synchronize():
perform_migration()
synchronize_payment_method()
update_a2billing_balance()
update_plan_consumption()
# Recargas
total_refills, amount = process_refills()
......@@ -529,7 +530,7 @@ def synchronize():
@app.command()
def test():
print(a2billing.account_data('956810498'))
print(a2billing.account_data('956384412'))
# update_a2billing_balance()
......
import pyodbc
import mariadb as mdb
from a2billing.a2billing import account_data
import os
sql_server_hostname = "192.168.2.200"
sql_server_database = "bdd_wifi"
sql_server_username = "api-mbilling"
sql_server_password = "mbillingmbilling"
sql_server_driver = 'ODBC Driver 17 for SQL Server' if os.name == 'nt' else 'FreeTDS'
DB_CREDENTIALS = {
'host': '192.168.2.84',
'user': 'scripts',
'password': 'scripts',
'port': 3306,
'database': 'mbilling'
}
# Cadena de Conexión
SQL_SERVER_CNX_STRING = "DRIVER={driver};SERVER={server};\
DATABASE={database};UID={username};PWD={password};TDS_Version=7.0;".format(
driver=sql_server_driver, server=sql_server_hostname,
database=sql_server_database, username=sql_server_username,
password=sql_server_password)
with pyodbc.connect(SQL_SERVER_CNX_STRING) as cnx:
with mdb.connect(**DB_CREDENTIALS) as cnx:
with cnx.cursor() as cursor:
cursor.execute(
'SELECT [ID], [DDI] \
FROM [bdd_wifi].[dbo].[TB_ServicioFijo] \
WHERE FechaBaja is NULL AND NuevaPlataforma=1 \
ORDER BY UsuarioWifi, UsuarioEXT DESC'
'SELECT id_prefix, rateinitial FROM mbilling.pkg_rate WHERE id_plan=4;'
)
for ddi in cursor.fetchall():
data = account_data(ddi[1])
for prefix in cursor.fetchall():
cursor.execute(
'UPDATE [bdd_wifi].[dbo].[TB_ServicioFijo] SET CuentaA2Billing=? WHERE ID=?',
(data['account'] if data else None, ddi[0])
'INSERT INTO pkg_rate (id_plan, id_trunk_group, id_prefix, rateinitial) VALUES (?,?,?,?)',
(5,1,prefix[0], prefix[1])
)
cnx.commit()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment