代码拉取完成,页面将自动刷新
同步操作将从 施超/flask_cmdb 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
# Author:shichao
# File: .py
import pymysql
# 封装连接
def getConnect():
try:
connection = pymysql.connect(
host="121.4.77.138",
user="cmdb",
password="Aa@963852",
database="cmdb",
port=3306)
return connection
except Exception as e:
print(e)
def selectByParameters(sql, params=None):
try:
connection = getConnect()
cursor = connection.cursor(pymysql.cursors.DictCursor)
cursor.execute(sql,params)
fc = cursor.fetchall()
return fc
except Exception as e:
print(e)
finally:
try:
cursor.close()
except Exception as e:
print(e)
try:
connection.close()
except Exception as e:
print(e)
def updateByParameters(sql, params=None):
try:
connection = getConnect()
cursor = connection.cursor(pymysql.cursors.DictCursor)
count = cursor.execute(sql,params)
connection.commit()
return count
except Exception as e:
connection.rollback()
print(e)
finally:
try:
cursor.close()
except Exception as e:
print(e)
try:
connection.close()
except Exception as e:
print(e)
if __name__ == '__main__':
sql = "select * from servers"
result = selectByParameters( sql )
print(result)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。