I am executing a select query which would return a single column and I am trying to convert the returned Row object to tuple. But I seem to be getting below error:
ids = sum(tuple(conn.execute('select id from some_database.some_table')), ())
TypeError: can only concatenate tuple (not "RowProxy") to tuple
Sample Code:
with sqlalchemy_engine.connect() as conn:
ids = sum(tuple(conn.execute('select id from some_database.some_table')), ()) # statement causing error
print(ids)
Expected Output:
('123','456','789')
I can iterate output of select query and append/print the values one by one, but would rather use the one-liner
Edit:
The column id
in query select id from some_database.some_table
has alphanumeric values. So the expected output could be:
('ff123', 'df456', 'gv789')