當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。