返回列表 发帖

CentOS8使用Python3脚本远程管理Oracle11gR2

笺注:这是在 Navicat连接Oracle11gR2 的基础上进行的。

实验中,客户端为CentOS8.2(64位)

客户端Python的版本:
[root@centos8 ~]# python3 --version
Python 3.6.8
[root@centos8 ~]#


客户端离线安装第三方库(cx_Oracle):
[root@centos8 ~]# ls *.whl
cx_Oracle-8.0.1-cp36-cp36m-manylinux1_x86_64.whl
[root@centos8 ~]#

[root@centos8 ~]# pip3 install cx_Oracle-8.0.1-cp36-cp36m-manylinux1_x86_64.whl
Processing ./cx_Oracle-8.0.1-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: cx-Oracle
Successfully installed cx-Oracle-8.0.1
[root@centos8 ~]#


列出当前环境所有已经安装的第三方库的名称和其版本号:
[root@centos8 ~]# pip3 freeze
cx-Oracle==8.0.1
[root@centos8 ~]#



CentOS8/Redhat8要安装oracle-instantclient19.9-basic:
[root@centos8 ~]# ls *.rpm
oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
[root@centos8 ~]#


客户端安装相关RPM包:(以本地光盘作为Yum源即可)
[root@centos8 ~]# yum -y install oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm

[root@centos8 ~]# sudo sh -c "echo /usr/lib/oracle/19.9/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
[root@centos8 ~]#
[root@centos8 ~]# cat /etc/ld.so.conf.d/oracle-instantclient.conf
/usr/lib/oracle/19.9/client64/lib
[root@centos8 ~]#

[root@centos8 ~]# sudo ldconfig
[root@centos8 ~]#



######

例子一:
客户端远程测试与数据库连接的脚本:(/root/xx.py)
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def db_connect():

        #远程连接数据库;Oracle服务器的IP地址为192.168.168.163
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
       
        cursor = db.cursor()
       
        Sql_1 = "SELECT version FROM product_component_version WHERE substr(product, 1, 6) = 'Oracle'" #查看数据库版本信息
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchone() #使用fetchone只能获取一个元素
        print(Result_1)
        print(type(Result_1))
       
        print("-" * 10)
        print(Result_1[0]) #输出元组的第一个元素
       
        print("-" * 10)
        print(f"数据库的版本信息:{Result_1[0]}")
       
        db.close() #关闭数据库连接

def func_main():
        try:
                db_connect()
        except Exception as e:
                print(f"数据库连接失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:(连接成功时)
[root@centos8 ~]# python3 xx.py
('11.2.0.1.0',)
<class 'tuple'>
----------
11.2.0.1.0
----------
数据库的版本信息:11.2.0.1.0
[root@centos8 ~]#


假如不配置好Oracle Instant Client会出现如下错误提示:
[root@centos8 ~]# python3 xx.py
数据库连接失败,原因: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
[root@centos8 ~]#



######

数据库用户happy已有的表STU_01的表结构:
图片1.png


例子二:
客户端远程一次性插入多条记录的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

import datetime
dt = datetime.datetime.now()
tt_1 = dt.strftime('%Y-%m-%d %H:%M:%S') #当前时间

def insert_record():
        global db
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
        cursor = db.cursor()
       
        Sql_1 = "INSERT into STU_01 (ID,NAME,AGE,GRADE,ADDRESS,MATH,CHINESE,SHIJIAN)" \
        " values (1,'小明',15,'三年二班','广东省,广州市',60.544,70.5444,to_timestamp('2020-10-5 19:3:15','yyyy-mm-ddhh24:mi:ss'))"
        cursor.execute(Sql_1)
       
       
        Key_1 = 2
        Key_2 = '李大杰'
        Key_3 = 16
        Key_4 = '三年二班'
        Key_5 = '广东省,佛山市'
        Key_6 = 66.555
        Key_7 = 78.5555
        Key_8 = "to_timestamp('2020-10-06 10:23:15','yyyy-mm-ddhh24:mi:ss')"
       
        Sql_2 = f"INSERT into STU_01 (ID,NAME,AGE,GRADE,ADDRESS,MATH,CHINESE,SHIJIAN) VALUES({Key_1},'{Key_2}',{Key_3},'{Key_4}','{Key_5}',{Key_6},{Key_7},{Key_8})"
        cursor.execute(Sql_2)

       
        Key_1 = 3
        Key_2 = 'Zhuohua'
        Key_3 = 18
        Key_4 = '三年十二班'
        Key_5 = '四川省,成都市'
        Key_6 = 100
        Key_7 = 99
        Key_8 = f"to_timestamp('{tt_1}','yyyy-mm-ddhh24:mi:ss')"
               
        Sql_3 = f"INSERT into STU_01 (ID,NAME,AGE,GRADE,ADDRESS,MATH,CHINESE,SHIJIAN) VALUES({Key_1},'{Key_2}',{Key_3},'{Key_4}','{Key_5}',{Key_6},{Key_7},{Key_8})"
        cursor.execute(Sql_3)
               
        db.commit() #把执行任务提交到数据库;必须是所有SQL语句都执行成功才会提交
        db.close()
               
def func_main():
        try:
                insert_record()
        except Exception as e:
                print(f"插入记录失败,原因: {e}")
                db.rollback() #如果发生错误就回滚
        else:
                print("插入记录成功。")
               
if __name__ == "__main__":

        func_main()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
插入记录成功。
[root@centos8 ~]#


插入记录成功:
图片2.png



######

例子三:
客户端远程输出数据库中某个表的所有记录的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
        cursor = db.cursor()
               
        Sql_1 = "select * from STU_01" #输出表STU_01中的所有记录
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchall() #使用fetchall可以获取多个元素
               
        for Key_1 in Result_1: #自定义输出格式
                ID = Key_1[0]
                NAME = Key_1[1]
                AGE = Key_1[2]
               
                GRADE = Key_1[3].strip() #去除左边和右边的空格、换行符
                ADDRESS = Key_1[4]
                MATH = Key_1[5]
                CHINESE = Key_1[6]
               
                SHIJIAN = str(Key_1[7])

                print(f"id={ID} (<;,;>) 姓名={NAME} (<;,;>) 年龄={AGE} (<;,;>) 班级={GRADE} (<;,;>) 地址={ADDRESS} (<;,;>) 数学成绩={MATH} (<;,;>) 语文成绩={CHINESE} (<;,;>) 时间={SHIJIAN}")
                       
        db.commit() #把执行任务提交到数据库
        db.close()

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05 19:03:15
id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06 10:23:15
id=3 (<;,;>) 姓名=Zhuohua (<;,;>) 年龄=18 (<;,;>) 班级=三年十二班 (<;,;>) 地址=四川省,成都市 (<;,;>) 数学成绩=100.0 (<;,;>) 语文成绩=99.0 (<;,;>) 时间=2022-07-08 19:23:59
[root@centos8 ~]#



######

例子四:
远程客户端根据时间范围输出某个表中符合条件的记录的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
        cursor = db.cursor()
               
        Key_1 = '2022-07-08' #日期范围
       
        Sql_1 = f"select * from STU_01 where to_char(SHIJIAN,'yyyy-mm-dd') < '{Key_1}'"
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchall()
               
        for Key_1 in Result_1: #自定义输出格式
                ID = Key_1[0]
                NAME = Key_1[1]
                AGE = Key_1[2]
               
                GRADE = Key_1[3].strip() #去除左边和右边的空格、换行符
                ADDRESS = Key_1[4]
                MATH = Key_1[5]
                CHINESE = Key_1[6]
               
                SHIJIAN = str(Key_1[7])

                print(f"id={ID} (<;,;>) 姓名={NAME} (<;,;>) 年龄={AGE} (<;,;>) 班级={GRADE} (<;,;>) 地址={ADDRESS} (<;,;>) 数学成绩={MATH} (<;,;>) 语文成绩={CHINESE} (<;,;>) 时间={SHIJIAN}")
                       
        db.commit() #把执行任务提交到数据库
        db.close()

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:(假如找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05 19:03:15
id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06 10:23:15
[root@centos8 ~]#


脚本运行的结果:(假如没有找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
[root@centos8 ~]#



######

例子五:
远程客户端根据时间范围输出某个表中符合条件的记录的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/orcl')
        cursor = db.cursor()
               
        Key_1 = '2022-07-08' #日期范围
       
        Sql_1 = f"select * from STU_01 where to_char(SHIJIAN,'yyyy-mm-dd') <= '{Key_1}'"
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchall()
               
        for Key_1 in Result_1: #自定义输出格式
                ID = Key_1[0]
                NAME = Key_1[1]
                AGE = Key_1[2]
               
                GRADE = Key_1[3].strip() #去除左边和右边的空格、换行符
                ADDRESS = Key_1[4]
                MATH = Key_1[5]
                CHINESE = Key_1[6]
               
                SHIJIAN = str(Key_1[7])

                print(f"id={ID} (<;,;>) 姓名={NAME} (<;,;>) 年龄={AGE} (<;,;>) 班级={GRADE} (<;,;>) 地址={ADDRESS} (<;,;>) 数学成绩={MATH} (<;,;>) 语文成绩={CHINESE} (<;,;>) 时间={SHIJIAN}")
                       
        db.commit() #把执行任务提交到数据库
        db.close()

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:(假如找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05 19:03:15
id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06 10:23:15
id=3 (<;,;>) 姓名=Zhuohua (<;,;>) 年龄=18 (<;,;>) 班级=三年十二班 (<;,;>) 地址=四川省,成都市 (<;,;>) 数学成绩=100.0 (<;,;>) 语文成绩=99.0 (<;,;>) 时间=2022-07-08 19:23:59
[root@centos8 ~]#


脚本运行的结果:(假如没有找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
[root@centos8 ~]#



######

例子六:
远程客户端根据时间范围输出某个表中符合条件的记录的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
        cursor = db.cursor()
               
        Key_1 = '2019-07-08' #日期范围
        Key_2 = '2020-10-06' #日期范围
       
        Sql_1 = f"select * from STU_01 where to_char(SHIJIAN,'yyyy-mm-dd') between '{Key_1}' and '{Key_2}'"
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchall()
               
        for Key_1 in Result_1: #自定义输出格式
                ID = Key_1[0]
                NAME = Key_1[1]
                AGE = Key_1[2]
               
                GRADE = Key_1[3].rstrip() #单单去除右边的空格、换行符
                ADDRESS = Key_1[4]
                MATH = Key_1[5]
                CHINESE = Key_1[6]
               
                SHIJIAN = str(Key_1[7])[0:10] #输出前面10个字符

                print(f"id={ID} (<;,;>) 姓名={NAME} (<;,;>) 年龄={AGE} (<;,;>) 班级={GRADE} (<;,;>) 地址={ADDRESS} (<;,;>) 数学成绩={MATH} (<;,;>) 语文成绩={CHINESE} (<;,;>) 时间={SHIJIAN}")
                       
        db.commit() #把执行任务提交到数据库
        db.close()

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:(假如找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05
id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06
[root@centos8 ~]#


脚本运行的结果:(假如没有找到匹配的记录时)
[root@centos8 ~]# python3 xx.py
[root@centos8 ~]#



######

例子七:
客户端远程输出根据聚合函数获得的数据的脚本:(结果只取一个值)
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():

        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')       
        cursor = db.cursor()
       
        Sql_1 = "select max(MATH) from STU_01" #求字段MATH中的最大值
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchone()
        print(Result_1)
        print(type(Result_1))
       
        print("-" * 10)
      
        print(Result_1[0])
        print(type(Result_1[0]))
       
        db.close() #关闭数据库连接

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
(100,)
<class 'tuple'>
----------
100
<class 'int'>

[root@centos8 ~]#



######

例子八:
客户端远程输出根据聚合函数获得的数据的脚本:(结果只取一个值)
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():

        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/orcl')       
        cursor = db.cursor()
       
        Sql_1 = "select max(MATH) from STU_01 group by GRADE having GRADE = '三年二班'" #求三年二班里MATH中的最大值
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchone()
        print(Result_1)
        print(type(Result_1))
       
        print("-" * 10)
      
        print(Result_1[0])
        print(type(Result_1[0]))
       
        db.close() #关闭数据库连接

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
(66.56,)
<class 'tuple'>
----------
66.56
<class 'float'>

[root@centos8 ~]#



######

例子九:
客户端远程保存(覆盖)数据库中某个表里符合指定条件的记录到文件的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def query_data():
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/orcl')
        cursor = db.cursor()
               
        Key_1 = '2022-07-08' #日期范围
       
        Sql_1 = f"select * from STU_01 where to_char(SHIJIAN,'yyyy-mm-dd') <= '{Key_1}'"
        cursor.execute(Sql_1)
       
        Result_1 = cursor.fetchall()
               
        for Key_1 in Result_1: #自定义输出格式
                ID = Key_1[0]
                NAME = Key_1[1]
                AGE = Key_1[2]
               
                GRADE = Key_1[3].rstrip() #单单去除右边的空格、换行符
                ADDRESS = Key_1[4]
                MATH = Key_1[5]
                CHINESE = Key_1[6]
               
                SHIJIAN = str(Key_1[7])

                print(f"id={ID} (<;,;>) 姓名={NAME} (<;,;>) 年龄={AGE} (<;,;>) 班级={GRADE} (<;,;>) 地址={ADDRESS} (<;,;>) 数学成绩={MATH} (<;,;>) 语文成绩={CHINESE} (<;,;>) 时间={SHIJIAN}")
                       
        db.commit() #把执行任务提交到数据库
        db.close()

def func_main():
        try:
                query_data()
        except Exception as e:
                print(f"输出失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:(文件1.txt不存在的话,会自动创建)
[root@centos8 ~]# python3 xx.py > 1.txt
[root@centos8 ~]#
[root@centos8 ~]# cat 1.txt
id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05 19:03:15
id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06 10:23:15
id=3 (<;,;>) 姓名=Zhuohua (<;,;>) 年龄=18 (<;,;>) 班级=三年十二班 (<;,;>) 地址=四川省,成都市 (<;,;>) 数学成绩=100.0 (<;,;>) 语文成绩=99.0 (<;,;>) 时间=2022-07-08 19:23:59
[root@centos8 ~]#



######

例子十:
客户端远程清空某个表的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def truncate_table():

        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')
        cursor = db.cursor()
  
        Sql_1 = "truncate table STU_01" #清空表STU_01
        cursor.execute(Sql_1)

        db.commit() #把执行任务提交到数据库
        db.close()

        print ("清空表STU_01成功。")

def func_main():
        try:
                truncate_table()
        except Exception as e:
                print(f"清空表失败,原因: {e}")

if __name__ == "__main__":

        func_main()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
清空表STU_01成功。
[root@centos8 ~]#


清空表STU_01成功:
图片3.png



######

例子十一:
远程客户端把本地文件里的所有记录添加到数据库中的某个表的脚本:
[root@centos8 ~]# cat xx.py
#coding=utf-8
import cx_Oracle

def func1():
        Path_1 = "./1.txt"
        f_name = open(Path_1,'r')
        Result_1 = f_name.readlines() #输出结果为列表,包含换行符
        f_name.close()
       
        print(Result_1)
        print(type(Result_1))
       
        insert_record(Result_1)  

       
def insert_record(Result_1):
        db = cx_Oracle.connect('happy/mima@192.168.168.163:1521/ORCL')       
        cursor = db.cursor()

        for Key_1 in Result_1:
               
                id = int(Key_1.split(' (<;,;>) ')[0][3:]) #去掉前面3个字符,再转换为整数
                name = Key_1.split(' (<;,;>) ')[1][3:] #去掉前面3个字符
                age =  int(Key_1.split(' (<;,;>) ')[2][3:]) #去掉前面3个字符,再转换为整数
               
                grade = Key_1.split(' (<;,;>) ')[3][3:] #以' (<;,;>) '为分隔符进行分割后,再取第4项
                address = Key_1.split(' (<;,;>) ')[4][3:]
               
                math = float(Key_1.split(' (<;,;>) ')[5][5:]) #去掉前面5个字符,再转换为浮点数
                chinese = float(Key_1.split(' (<;,;>) ')[6][5:]) #去掉前面5个字符,再转换为浮点数
               
                shijian_1 = Key_1.split(' (<;,;>) ')[7][3:].rstrip('\n') #去掉前面3个字符,再去除右边的换行符
                shijian_2 = f"to_timestamp('{shijian_1}','yyyy-mm-ddhh24:mi:ss')"
               
                Sql_1 = f"INSERT into STU_01 (ID,NAME,AGE,GRADE,ADDRESS,MATH,CHINESE,SHIJIAN)" \
                f" VALUES({id},'{name}',{age},'{grade}','{address}',{math},{chinese},{shijian_2})"
               
                cursor.execute(Sql_1)
               
        db.commit() #把执行任务提交到数据库
        db.close()
               
               
if __name__ == "__main__":

        func1()


脚本运行的结果:
[root@centos8 ~]# python3 xx.py
['id=1 (<;,;>) 姓名=小明 (<;,;>) 年龄=15 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,广州市 (<;,;>) 数学成绩=60.54 (<;,;>) 语文成绩=70.544 (<;,;>) 时间=2020-10-05 19:03:15\n', 'id=2 (<;,;>) 姓名=李大杰 (<;,;>) 年龄=16 (<;,;>) 班级=三年二班 (<;,;>) 地址=广东省,佛山市 (<;,;>) 数学成绩=66.56 (<;,;>) 语文成绩=78.556 (<;,;>) 时间=2020-10-06 10:23:15\n', 'id=3 (<;,;>) 姓名=Zhuohua (<;,;>) 年龄=18 (<;,;>) 班级=三年十二班 (<;,;>) 地址=四川省,成都市 (<;,;>) 数学成绩=100.0 (<;,;>) 语文成绩=99.0 (<;,;>) 时间=2022-07-08 19:23:59\n']
<class 'list'>
[root@centos8 ~]#


记录添加成功:
图片4.png





############
############

客户端卸载安装第三方库(cx_Oracle):
[root@centos8 ~]# pip3 uninstall cx_Oracle -y
Uninstalling cx-Oracle-8.0.1:
  Successfully uninstalled cx-Oracle-8.0.1

[root@centos8 ~]#


查看Oracle Instant Client的版本信息: (模糊查询)
[root@centos8 ~]# rpm -qa |grep oracle-instantclient
oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64
[root@centos8 ~]#


查看Oracle Instant Client的版本信息等: (详细信息)
[root@centos8 ~]# rpm -qi oracle-instantclient19.9-basic
Name        : oracle-instantclient19.9-basic
Version     : 19.9.0.0.0
Release     : 1
Architecture: x86_64
Install Date: 2022年07月09日 星期六 09时49分38秒
Group       : Applications/File
Size        : 237428378
License     : Oracle
Signature   : (none)
Source RPM  : oracle-instantclient19.9-basic-19.9.0.0.0-1.src.rpm
Build Date  : 2020年10月01日 星期四 03时30分29秒
Build Host  : adc00jxi.us.oracle.com
Relocations : (not relocatable)
Packager    : Nobody <nobody@oracle.com>
Vendor      : Oracle Corporation
URL         : https://www.oracle.com/
Summary     : Oracle Instant Client Basic package
Description :
The Oracle Instant Client Basic package provides libraries for Oracle Call Interface (OCI), Oracle C++ Call Interface (OCCI), and JDBC applications to connect to a local or remote Oracle Database for development and production deployment. The Instant Client libraries provide all necessary network connectivity, as well as basic and high-end data access features.
[root@centos8 ~]#


客户端卸载Oracle Instant Client:(以本地光盘作为Yum源即可)
[root@centos8 ~]# yum -y remove oracle-instantclient19.9-basic


Oracle Instant Client已卸载成功:
[root@centos8 ~]# rpm -qi oracle-instantclient19.9-basic
未安装软件包 oracle-instantclient19.9-basic
[root@centos8 ~]#





相关文章:
Python3脚本管理Oracle11gR2
CentOS6_RPM软件包管理器(screen+mailx)

Zabbix调用Python3脚本监控Linux下的Oracle(二)
CentOS8使用Python3脚本管理MySQL8.0

返回列表