本文整理汇总了Python中cx_Oracle.Error方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.Error方法的具体用法?Python cx_Oracle.Error怎么用?Python cx_Oracle.Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cx_Oracle
的用法示例。
在下文中一共展示了cx_Oracle.Error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_environment
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def _setup_environment(environ):
# Cygwin requires some special voodoo to set the environment variables
# properly so that Oracle will see them.
if platform.system().upper().startswith('CYGWIN'):
try:
import ctypes
except ImportError as e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading ctypes: %s; "
"the Oracle backend requires ctypes to "
"operate correctly under Cygwin." % e)
kernel32 = ctypes.CDLL('kernel32')
for name, value in environ:
kernel32.SetEnvironmentVariableA(name, value)
else:
os.environ.update(environ)
示例2: db_connect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [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
示例3: is_usable
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def is_usable(self):
try:
self.connection.ping()
except Database.Error:
return False
else:
return True
示例4: _setup_environment
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def _setup_environment(environ):
# Cygwin requires some special voodoo to set the environment variables
# properly so that Oracle will see them.
if platform.system().upper().startswith('CYGWIN'):
try:
import ctypes
except ImportError as e:
raise ImproperlyConfigured("Error loading ctypes: %s; "
"the Oracle backend requires ctypes to "
"operate correctly under Cygwin." % e)
kernel32 = ctypes.CDLL('kernel32')
for name, value in environ:
kernel32.SetEnvironmentVariableA(name, value)
else:
os.environ.update(environ)