my requirements is following. Find a count(*) for a table and if not exists, create one.following is the sample code to show the issue. in both cases the else condition is coming. not sure how I achieve this, any help is appreciated.
import cx_Oracle
import os
import datetime
ts = datetime.datetime.now()
con = cx_Oracle.connect('xxxx/xxxx@xxxxx: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
Aucun commentaire:
Enregistrer un commentaire