In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to connect to the oracle database in Python, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1. Basic connection-using Oracle tns alias
Connection=cx_Oracle.connect ("tp/tp@ocn_test") # View the tns alias command cmd > tnsping ocn_test TNS Ping Utility forLinux: Version 9.2.0.8.0-Production on 27-SEP-201110:47:48Copyright (c) 1997 and 2006, Oracle Corporation. Allrights reserved.Used parameter files:/opt/... / sqlnet.oraUsed TNSNAMES adapter to resolve the aliasAttempting to contact (DESCRIPTION = (ADDRESS_LIST= (ADDRESS= (PROTOCOL=TCP) (HOST=10.20.36.19) (PORT=1520) (CONNECT_DATA = (SID=ocntest)) OK (10msec)
two。 User enters password to connect
Pwd=getpass.getpass () connection=cx_Oracle.connect ("tp", pwd, "ocn_test")
3. The user enters the connection account information directly in the Python command, such as python script.py tp/tp@ocn_test
Connection=cx_Oracle.connect (sys.argv [1]) 4. Using Easy Connect syntax, connect to the database connection=cx_Oracle.connect ('tp','tp','10.20.36.19:1521/ocntest') # orconnection=cx_Oracle.connect (' tp/tp@10.20.36.19:1521/ocntest') through Drive
5. First use DSN to form TNSNAME
Tns_name=cx_Oracle.makedsn ('10.20.36.19) connection=cx_Oracle.connect (' tp','tp',tns_name)
6. Log in to as SYSDBA
Connection=cx_Oracle.connect ('tp/tp@ocn_test', mode=cx_Oracle.SYSDBA) # or as SYSOPERconnection=cx_Oracle.connect (' tp/tp@ocn_test', mode=cx_Oracle.SYSOPER) about how to connect to the oracle database in Python is shared here. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.