-1
私の要件は次のとおりです。テーブルのカウント(*)を見つけ、存在しない場合は、テーブルを作成します。次に、問題を示すサンプルコードを示します。どちらの場合もelse条件が発生します。どのように私はこれを達成するかわからない、どんな助けもありがとう。python oracle他の行がフェッチする場合
import cx_Oracle
import os
import datetime
ts = datetime.datetime.now()
con = cx_Oracle.connect('xxxx/[email protected]:1521/xxxxx')
print con.version
cur = con.cursor()
cur.execute('select count(*) from AAA.AAA_TEST')
rows = cur.fetchall();
print rows
print len(rows)
if (rows ==1):
print 'there is a row'
else:
print 'there is no row'
#result 1 where the row exists
11.2.0.4.0
[(1,)]
1
there is no row
Process finished with exit code 0
#result 2 where the row do not exists
11.2.0.4.0
[(0,)]
1
there is no row
Process finished with exit code 0
コードで表示されている場合は申し訳ありませんが、 – Shanker
変更されたコードは役に立ちますか? – phd
申し訳ありませんが、しばらくお待ちください、私はあなたを更新します。このように動作するようです。私はいくつかのテストをしましょう。前もって感謝します。 – Shanker