# cx_oracle_instant_client **Repository Path**: eccom21/cx_oracle_instant_client ## Basic Information - **Project Name**: cx_oracle_instant_client - **Description**: cx_oracle 连接oracle数据库时,提示 缺少 lib; 可以从这里下载 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-03-04 - **Last Updated**: 2024-02-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 使用方法 1. 将zip包 解压到 /opt/instantclient_basic/ 目录下 2. cx_oracle 代码指定这个路径 ``` """ 使用 cx_Oracle 连接 Oracle 数据库 """ import cx_Oracle # 根据情况 自己替换 instantclient_lib = "/opt/instantclient_basic/mac" cx_Oracle.init_oracle_client(lib_dir=instantclient_lib) connection = cx_Oracle.connect(user="dev", password="dev", dsn="localhost/helowin") print("Successfully connected to Oracle Database") cursor = connection.cursor() # Insert some data rows = [("Task 1", 0), ("Task 2", 0), ("Task 3", 1), ("Task 4", 0), ("Task 5", 1)] cursor.executemany("insert into todoitem (description, done) values(:1, :2)", rows) print(cursor.rowcount, "Rows Inserted") connection.commit() # Now query the rows back for row in cursor.execute('select description, done from todoitem'): if row[1]: print(row[0], "is done") else: print(row[0], "is NOT done") cursor.close() connection.close() ```