db=cx_Oracle.connect('bidb/bidb@BI155')或connect('bidb','bidb','bi155') cursor = db.cursor() query = "select banner from v$version" cursor.execute(query) rows = cursor.fetchall() for row in rows: print row[0] db.close()
注意缩进,若是用UE编辑,要注意选项中制表符到空格转换的设置,若用多种编辑器混合编辑时可能会引发问题。 输出:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
原创文章,作者:苏葳,如需转载,请注明出处:https://www.swmemo.com/416.html