Oracle syskm,Python cx_Oracle.SYSDBA属性代码示例
发布日期:2021-06-24 13:08:32 浏览次数:3 分类:技术文章

本文共 1117 字,大约阅读时间需要 3 分钟。

# 需要导入模块: import cx_Oracle [as 别名]

# 或者: from cx_Oracle import SYSDBA [as 别名]

def db_connect(args):

if args.type == "mysql" or args.type == "mariadb":

import mysql.connector

try:

connection = mysql.connector.connect(

user=args.user,

password=args.password,

database=args.db)

except mysql.connector.Error as err:

print(colorize("red", "[ERROR] {}".format(err)))

return None

elif args.type == "mssql":

import pymssql

try:

connection = pymssql.connect(server="localhost", database=args.db)

except pymssql.Error as err:

print(colorize("red", "[ERROR] {}".format(err)))

return None

elif args.type == "pgsql":

import psycopg2

try:

connection = psycopg2.connect(

"dbname='{}' user='{}' password='{}'".format(

args.db, args.user, args.password))

except psycopg2.Error as err:

print(colorize("red", "[ERROR] {}".format(err)))

return None

elif args.type == "oracle":

import cx_Oracle

try:

connection = cx_Oracle.connect(

args.user, args.password, cx_Oracle.makedsn(

'127.0.0.1', 1521, args.db), mode=cx_Oracle.SYSDBA)

except cx_Oracle.Error as err:

print(colorize("red", "[ERROR] {}".format(err)))

return None

return connection

转载地址:https://blog.csdn.net/weixin_32956805/article/details/116522900 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:oracle的osw是什么,Tools:OSW工具-Oracle的OS watcher
下一篇:oracle 查找所有有数据的表,Oracle 查找数据库中有记录的表

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月26日 15时00分26秒