当前位置: 首页>>代码示例>>Python>>正文


Python cx_Oracle.makedsn方法代码示例

本文整理汇总了Python中cx_Oracle.makedsn方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.makedsn方法的具体用法?Python cx_Oracle.makedsn怎么用?Python cx_Oracle.makedsn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cx_Oracle的用法示例。


在下文中一共展示了cx_Oracle.makedsn方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def connect(self):
        self.initConnection()
        self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db)
        self.__dsn = utf8encode(self.__dsn)
        self.user = utf8encode(self.user)
        self.password = utf8encode(self.password)

        try:
            self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA)
            logger.info("successfully connected as SYSDBA")
        except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), ex:
            if "Oracle Client library" in str(ex):
                msg = re.sub(r"DPI-\d+:\s+", "", str(ex))
                msg = re.sub(r': ("[^"]+")', r" (\g<1>)", msg)
                msg = re.sub(r". See (http[^ ]+)", r'. See "\g<1>"', msg)
                raise SqlmapConnectionException(msg)

            try:
                self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password)
            except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), msg:
                raise SqlmapConnectionException(msg) 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:23,代码来源:connector.py

示例2: execute

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def execute(self, host, port='1521', user='', password='', sid='', service_name=''):

    if sid:
      dsn = cx_Oracle.makedsn(host=host, port=port, sid=sid)
    elif service_name:
      dsn = cx_Oracle.makedsn(host=host, port=port, service_name=service_name)
    else:
      raise ValueError('Options sid and service_name cannot be both empty')

    try:
      with Timing() as timing:
        fp = cx_Oracle.connect(user, password, dsn, threaded=True)

      code, mesg = '0', fp.version

    except cx_Oracle.DatabaseError as e:
      code, mesg = e.args[0].message[:-1].split(': ', 1)

    return self.Response(code, mesg, timing)

# }}}

# PostgreSQL {{{ 
开发者ID:lanjelot,项目名称:patator,代码行数:25,代码来源:patator.py

示例3: db_connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [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 
开发者ID:migolovanov,项目名称:libinjection-fuzzer,代码行数:40,代码来源:fuzzer.py

示例4: _connect_string

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def _connect_string(self):
        settings_dict = self.settings_dict
        if not settings_dict['HOST'].strip():
            settings_dict['HOST'] = 'localhost'
        if settings_dict['PORT'].strip():
            dsn = Database.makedsn(settings_dict['HOST'],
                                   int(settings_dict['PORT']),
                                   settings_dict['NAME'])
        else:
            dsn = settings_dict['NAME']
        return "%s/%s@%s" % (settings_dict['USER'],
                             settings_dict['PASSWORD'], dsn) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:14,代码来源:base.py

示例5: __init__

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def __init__(self, **keywords):
        import cx_Oracle as db

        if 'pw' in keywords:
            keywords['password'] = keywords.pop('pw')

            #@@ TODO: use db.makedsn if host, port is specified
        keywords['dsn'] = keywords.pop('db')
        self.dbname = 'oracle'
        db.paramstyle = 'numeric'
        self.paramstyle = db.paramstyle

        # oracle doesn't support pooling
        keywords.pop('pooling', None)
        DB.__init__(self, db, keywords) 
开发者ID:mqingyn,项目名称:torngas,代码行数:17,代码来源:basedb.py

示例6: __init__

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def __init__(self, **keywords): 
        import cx_Oracle as db 
        if 'pw' in keywords: 
            keywords['password'] = keywords.pop('pw') 

        #@@ TODO: use db.makedsn if host, port is specified 
        keywords['dsn'] = keywords.pop('db') 
        self.dbname = 'oracle' 
        db.paramstyle = 'numeric' 
        self.paramstyle = db.paramstyle

        # oracle doesn't support pooling 
        keywords.pop('pooling', None) 
        DB.__init__(self, db, keywords) 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:16,代码来源:db.py

示例7: _connect_string

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def _connect_string(self):
        settings_dict = self.settings_dict
        if not settings_dict['HOST'].strip():
            settings_dict['HOST'] = 'localhost'
        if settings_dict['PORT']:
            dsn = Database.makedsn(settings_dict['HOST'],
                                   int(settings_dict['PORT']),
                                   settings_dict['NAME'])
        else:
            dsn = settings_dict['NAME']
        return "%s/%s@%s" % (settings_dict['USER'],
                             settings_dict['PASSWORD'], dsn) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:14,代码来源:base.py

示例8: test_get_conn_sid

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def test_get_conn_sid(self, mock_connect):
        dsn_sid = {'dsn': 'dsn', 'sid': 'sid'}
        self.connection.extra = json.dumps(dsn_sid)
        self.db_hook.get_conn()
        assert mock_connect.call_count == 1
        args, kwargs = mock_connect.call_args
        self.assertEqual(args, ())
        self.assertEqual(kwargs['dsn'],
                         cx_Oracle.makedsn(dsn_sid['dsn'],
                                           self.connection.port, dsn_sid['sid'])) 
开发者ID:apache,项目名称:airflow,代码行数:12,代码来源:test_oracle.py

示例9: test_get_conn_service_name

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def test_get_conn_service_name(self, mock_connect):
        dsn_service_name = {'dsn': 'dsn', 'service_name': 'service_name'}
        self.connection.extra = json.dumps(dsn_service_name)
        self.db_hook.get_conn()
        assert mock_connect.call_count == 1
        args, kwargs = mock_connect.call_args
        self.assertEqual(args, ())
        self.assertEqual(kwargs['dsn'], cx_Oracle.makedsn(
            dsn_service_name['dsn'], self.connection.port,
            service_name=dsn_service_name['service_name'])) 
开发者ID:apache,项目名称:airflow,代码行数:12,代码来源:test_oracle.py

示例10: connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def connect(self):
        self.initConnection()
        self.__dsn = cx_Oracle.makedsn(self.hostname, self.port, self.db)
        self.__dsn = utf8encode(self.__dsn)
        self.user = utf8encode(self.user)
        self.password = utf8encode(self.password)

        try:
            self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password, mode=cx_Oracle.SYSDBA)
            logger.info("successfully connected as SYSDBA")
        except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError):
            try:
                self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password)
            except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError, cx_Oracle.InterfaceError), msg:
                raise SqlmapConnectionException(msg) 
开发者ID:krintoxi,项目名称:NoobSec-Toolkit,代码行数:17,代码来源:connector.py

示例11: _dsn

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def _dsn(self):
        settings_dict = self.settings_dict
        if not settings_dict['HOST'].strip():
            settings_dict['HOST'] = 'localhost'
        if settings_dict['PORT']:
            return Database.makedsn(settings_dict['HOST'], int(settings_dict['PORT']), settings_dict['NAME'])
        return settings_dict['NAME'] 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:9,代码来源:base.py

示例12: get_connection

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def get_connection(self, db_name=None):
        if self.conn:
            return self.conn
        if self.sid:
            dsn = cx_Oracle.makedsn(self.host, self.port, self.sid)
            self.conn = cx_Oracle.connect(self.user, self.password, dsn=dsn, encoding="UTF-8", nencoding="UTF-8")
        elif self.service_name:
            dsn = cx_Oracle.makedsn(self.host, self.port, service_name=self.service_name)
            self.conn = cx_Oracle.connect(self.user, self.password, dsn=dsn, encoding="UTF-8", nencoding="UTF-8")
        else:
            raise ValueError('sid 和 dsn 均未填写, 请联系管理页补充该实例配置.')
        return self.conn 
开发者ID:hhyo,项目名称:Archery,代码行数:14,代码来源:oracle.py

示例13: conn_oracle

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def conn_oracle(self):
        self.data = self.conlist
        try:
            tns_name = cx_Oracle.makedsn(self.conlist[2], self.conlist[3], "%s"%self.xe)
            db = cx_Oracle.connect(self.conlist[0],self.conlist[1], tns_name)
            return db
        except:
            self.col.printGreen(u"warning!!!!!!!!!!!!!!!!!!!\n程序出错!\n")
            print "\n"
            self.col.printRed(u"脚本连接服务器失败 ,请检查的你的用户名以及密码。或者是否数据库开启权限外链!")
            sys.exit() 
开发者ID:LiodAir,项目名称:AssmentToolss,代码行数:13,代码来源:Database_Oracle.py

示例14: check_statue

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import makedsn [as 别名]
def check_statue(self):
        """
        @函数方法:检测错误
        :return: 
        """
        self.data = self.conlist
        try:
            tns_name = cx_Oracle.makedsn(self.conlist[2], self.conlist[3], "%s"%self.xe)
            cx_Oracle.connect(self.conlist[0], self.conlist[1], tns_name)
            return (10086, 'access')
        except Exception as e:
            return e 
开发者ID:LiodAir,项目名称:AssmentToolss,代码行数:14,代码来源:Database_Oracle.py


注:本文中的cx_Oracle.makedsn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。