I'm new with Python and trying to add some data from an Oracle table to an array and add another value as datetime (string) for record.
My code is:
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
con = cx_Oracle.connect('user', 'pass', dsn_tns)
q='SELECT columns FROM table'
device_status = []
cursor = con.cursor()
cursor.execute(q)
results = cursor.fetchall()
for row in results:
device_status.append(row + tuple(now))
con.close()
print device_status[1]
This is the output:
('1110', '1000074', 2060, '2', '0', '1', '7', '-', '0', '2', '-', '2', '3', ' ', '1', '1', ':', '5', '2', ':', '0', '2')
I want to join the date so the output will look like:
('1110', '1000074', 2060,'2017-02-23 11:57:41')
Tried to use join but got the following error:
can only concatenate tuple (not "str") to tuple
What am I doing wrong?