本文整理汇总了Python中mysql.connector.MySQLConnection.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python MySQLConnection.disconnect方法的具体用法?Python MySQLConnection.disconnect怎么用?Python MySQLConnection.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.connector.MySQLConnection
的用法示例。
在下文中一共展示了MySQLConnection.disconnect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from mysql.connector import MySQLConnection [as 别名]
# 或者: from mysql.connector.MySQLConnection import disconnect [as 别名]
old_stdout = sys.stdout
sys.stdout = open(os.getcwd()+'/logs.txt', 'w')
print('Отчёт работы программы {}\n - - - - - - - - - '
.format(now_time.strftime('%d.%m.%Y %I:%M %p')))
try:
db_config = read_db_config()
cnx = MySQLConnection(**db_config)
print('Подключение к базе данных прошло успешно')
cursor = cnx.cursor(buffered=True)
tables_list = [
Table('CalculationTasks', 'id'), Table('EphemeridesGlonass', 'id'), Table('LoadedArchives', 'id'),
Table("LoadedRinexFiles", "id"), Table("Messages", "message_id"), Table("SatellitesStatuses", "id"),
Table("SatFiles", "id"), Table("Stations", "id"), Table("StationsReliability", "id"), Table("UEREs", "id")
]
for table in tables_list:
# блокировка, вызов функции изменения и разблокировка таблицы
cursor.execute('Lock TABLES {0} WRITE'.format(table.name))
table.ResetCounter()
cursor.execute('UNLOCK TABLES')
cursor.close()
cnx.disconnect()
except mysql.connector.Error as err:
print(' - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -\n'
'Произошла ошибка:\n Error code: {0}\n Error message: {1}'.format(err.errno, err.msg))
finally:
print('==========================================================================\n')
sys.stdout.close()
sys.stdout = old_stdout