From f02597292f17572701b15d2688b9ce4e3b8f3932 Mon Sep 17 00:00:00 2001 From: xuezhixin Date: Fri, 1 Nov 2024 18:07:19 +0800 Subject: [PATCH] add execution sql function --- 0005-execution-sql-function.patch | 62 +++++++++++++++++++++++++++++++ migration-tools.spec | 6 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 0005-execution-sql-function.patch diff --git a/0005-execution-sql-function.patch b/0005-execution-sql-function.patch new file mode 100644 index 0000000..1e0d4bb --- /dev/null +++ b/0005-execution-sql-function.patch @@ -0,0 +1,62 @@ +From 8dd714b9fe161358f48857fff9a08faac2af6af4 Mon Sep 17 00:00:00 2001 +From: lixin +Date: Mon, 6 Nov 2023 17:44:45 +0800 +Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8Csql=E8=AF=AD=E5=8F=A5?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + connect_sql.py | 39 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +diff --git a/connect_sql.py b/connect_sql.py +index e24a467..b5d0570 100644 +--- a/connect_sql.py ++++ b/connect_sql.py +@@ -28,3 +28,42 @@ class DBHelper: + self.cursor.close() + self.connect.close() + return True ++ ++ def execute(self, sql): ++ """ ++ 传入查询 修改 删除sql语句 ++ :param sql: ++ :return:self.cursor ++ """ ++ self.connectDatabase() ++ # 处理显示的数据 ++ try: ++ self.cursor.execute(sql) ++ self.connect.commit() ++ except Exception as e: ++ print('%s执行失败:%s' % (sql, e)) ++ else: ++ self.close() ++ print('%s 执行成功' % sql) ++ data = self.cursor ++ return data ++ ++ def insert(self, sql, val): ++ """ ++ 传入sql语句 ++ :param sql: ++ :return:self.cursor ++ 如果想获取查询数据需要fetchall() ++ """ ++ self.connectDatabase() ++ # 处理显示的数据 ++ try: ++ self.cursor.executemany(sql, val) ++ self.connect.commit() ++ except Exception as e: ++ print('%s执行失败:%s' % (sql, e)) ++ else: ++ self.close() ++ print('%s 执行成功' % sql) ++ data = self.cursor ++ return data +-- +2.20.1 + diff --git a/migration-tools.spec b/migration-tools.spec index 5e4883d..9e36c23 100644 --- a/migration-tools.spec +++ b/migration-tools.spec @@ -1,6 +1,6 @@ Name: migration-tools Version: 1.0.2 -Release: 4 +Release: 5 License: MulanPSL-2.0 Summary: A tool to help users migrate the Centos system to the UOS system and openEuler system Source0: %{name}-%{version}.tar.gz @@ -11,6 +11,7 @@ Patch0: 0001-format-code.patch Patch1: 0002-modify-excel-report-content.patch Patch2: 0003-delete-redundant-code.patch Patch3: 0004-connect-sql-function.patch +Patch4: 0005-execution-sql-function.patch BuildArch: noarch BuildRequires: systemd @@ -109,6 +110,9 @@ rm -rf /usr/bin/migration-tools %endif %changelog +* Fri Nov 1 2024 xuezhixin - 1.0.2-5 +- add 0005-execution-sql-function.patch + * Fri Nov 1 2024 xuezhixin - 1.0.2-4 - add 0004-connect-sql-function.patch