0

I'm new to SqlAlchemy and I'm Trying to create a Union of Two tables,

I have TableA with 5 columns Col1, Col2, Col3, Col4 and Col5.

and TableB with 3 columns Col1, Col2 and Col3.

what i need is something like

Select Col1, Col2, Col3, Col4, Col5 from TableA
Union
Select Col1, Col2, Col3, Null as Col4, Null as Col5 from TableB

How can i implement this using SQLAlchemy?

Thanks in advance

  • Though for subqueries, you can ger the idea from https://stackoverflow.com/questions/20024744/how-to-union-two-subqueries-in-sqlalchemy-and-postgresql – Ilja Everilä Jun 02 '20 at 18:35
  • the link solves some of my problems, but still i need to get a null value for a field that does not exist. – Sachin Whiteman D Jun 03 '20 at 04:24
  • That you can solve using this: https://stackoverflow.com/questions/7533146/how-do-i-select-literal-values-in-an-sqlalchemy-query. – Ilja Everilä Jun 03 '20 at 12:14

0 Answers0