使用特定传出端口的python-oracle

2024-04-25 05:30:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用cx\u Oracle模块将Python脚本连接到Oracle数据库。下面的正常连接脚本将使用随机端口(源IP:随机端口)向Oracle数据库(目标IP:1521)发送请求

   def oracle_query(oracle_olt):
     connection = cx_Oracle.connect('username/db@X.X.X.X:1521/sysdb');
     cursor = connection.cursor();
     print cur_time() + '- Oracle: QUERY data for ' + oracle_olt + ' \t\t\t...',
     cursor.execute("SELECT count(nasportid) FROM c280_callstatus where nasportid like " +  oracle_olt + "");
     row = cursor.fetchone();
     print 'OK!'
   connection.close();
   return row[0]  

问题:

是否有任何方法可以指定用于连接Oracle数据库的传出端口,例如(源IP:2002)-->;(Oracle数据库IP:1521)。提前谢谢


Tags: 模块端口ip脚本数据库目标connectioncursor