Change exchange_export.py adcontroller_export.py
rds_export.py
This commit is contained in:
+4
-16
@@ -1,18 +1,10 @@
|
||||
import requests
|
||||
import csv
|
||||
import mysql.connector
|
||||
from datetime import datetime
|
||||
import mysql_connect
|
||||
|
||||
|
||||
def smtp(ip,name,mailcow_token):
|
||||
|
||||
connection = mysql.connector.connect(
|
||||
host="172.17.1.21",
|
||||
user="root",
|
||||
password="N53yBCswuawzBzS445VNAhWVMs3N59Gb9szEsrzXRBzarDqpdETpQeyt5v5CGe",
|
||||
database="" + name
|
||||
)
|
||||
cursor = connection.cursor()
|
||||
|
||||
mailcow_url = f"http://{ip}/api/v1"
|
||||
mailcow_token = f"{mailcow_token}"
|
||||
|
||||
@@ -55,8 +47,7 @@ def smtp(ip,name,mailcow_token):
|
||||
field = 'User-ID'
|
||||
create_table_query += f"`{field}` TEXT, "
|
||||
create_table_query = create_table_query.rstrip(", ") + ")"
|
||||
cursor.execute(create_table_query)
|
||||
connection.commit()
|
||||
mysql_connect.create_database(create_table_query,name)
|
||||
|
||||
print(len(fields))
|
||||
columns = ", ".join(json_data[0].keys())
|
||||
@@ -71,7 +62,4 @@ def smtp(ip,name,mailcow_token):
|
||||
for entry in json_data:
|
||||
values = tuple(
|
||||
cell if isinstance(cell, int) else cell.strip() if cell.strip() else "-" for cell in entry.values())
|
||||
cursor.execute(insert_query, (unix_time,) + values)
|
||||
connection.commit()
|
||||
|
||||
connection.close()
|
||||
mysql_connect.add_user(insert_query,name, (unix_time,) + values)
|
||||
|
||||
Reference in New Issue
Block a user