本文整理汇总了Python中cx_Oracle.connect方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.connect方法的具体用法?Python cx_Oracle.connect怎么用?Python cx_Oracle.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cx_Oracle
的用法示例。
在下文中一共展示了cx_Oracle.connect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bind
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def bind(self, host, port, *args, **kwargs):
hp = '%s:%s' % (host, port)
key = ':'.join(map(str, args))
if hp in self.cache:
k, c = self.cache[hp]
if key == k:
self.curr = hp, k, c
return c.fp, c.banner
else:
c.close()
del self.cache[hp]
self.curr = None
logger.debug('connect')
conn = self.connect(host, port, *args, **kwargs)
self.cache[hp] = (key, conn)
self.curr = hp, key, conn
return conn.fp, conn.banner
示例2: connect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def connect(self, host, port, ssl, helo, starttls, timeout):
if ssl == '0':
if not port:
port = 25
fp = SMTP(timeout=int(timeout))
else:
if not port:
port = 465
fp = SMTP_SSL(timeout=int(timeout))
resp = fp.connect(host, int(port))
if helo:
cmd, name = helo.split(' ', 1)
if cmd.lower() == 'ehlo':
resp = fp.ehlo(name)
else:
resp = fp.helo(name)
if not starttls == '0':
resp = fp.starttls()
return TCP_Connection(fp, resp)
示例3: execute
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [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 {{{
示例4: oracle
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def oracle(self, ip):
for i in range(1, len(oracle_user)):
try:
user = oracle_user[i]
pwd = oracle_pass_default[i]
conn = cx_Oracle.connect(user, pwd, ip+':1521/orcl')
print u'{}[+] {}:1521 Oracle存在弱口令: {} {}{}'.format(G, ip, user, pwd, W)
conn.close()
except Exception as e:
pass
for pwd in passwd:
try:
pwd = pwd.replace('{user}', 'sys')
conn = cx_Oracle.connect('sys', pwd, ip+':1521/orcl')
print u'{}[+] {}:1521 Oracle存在弱口令: sys {}{}'.format(G, ip, pwd, W)
conn.close()
break
except Exception as e:
pass
示例5: redis
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def redis(self, ip):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, 6379))
s.send('INFO\r\n')
if 'redis_version' in s.recv(1024):
print u'{}[+] {}:6379 Redis存在未授权访问{}'.format(G, ip, W)
else:
for pwd in passwd:
try:
pwd = pwd.replace('{user}', 'admin')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, 6379))
s.send('AUTH {}\r\n'.format(pwd))
if '+OK' in s.recv(1024):
print u'{}[+] {}:6379 Redis存在弱口令: {}{}'.format(G, ip, pwd, W)
break
except Exception as e:
pass
finally:
s.close()
except Exception as e:
pass
finally:
s.close()
示例6: connect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def connect(self, host, port, ssl, helo, starttls, timeout):
if ssl == '0':
if not port: port = 25
fp = SMTP(timeout=int(timeout))
else:
if not port: port = 465
fp = SMTP_SSL(timeout=int(timeout))
resp = fp.connect(host, int(port))
if helo:
cmd, name = helo.split(' ', 1)
if cmd.lower() == 'ehlo':
resp = fp.ehlo(name)
else:
resp = fp.helo(name)
if not starttls == '0':
resp = fp.starttls()
return TCP_Connection(fp, resp)
示例7: connect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [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)
示例8: db_connect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [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
示例9: _open_connection
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def _open_connection(self):
return pymysql.connect(host=self.host,
port=self.port,
user=self.user,
password=self.password,
database=self._mysql_database)
示例10: get_new_connection
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def get_new_connection(self, conn_params):
conn_string = convert_unicode(self._connect_string())
return Database.connect(conn_string, **conn_params)
示例11: get_new_connection
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import connect [as 别名]
def get_new_connection(self, conn_params):
return Database.connect(self._connect_string(), **conn_params)