Its really superb. Its works like charm. Thanks a lot Mike Bayer.

On Sunday, May 6, 2018 at 6:46:11 PM UTC+5:30, Mike Bayer wrote:
>
> On Sun, May 6, 2018 at 4:15 AM,  <siddhesh@erpdata.cloud> wrote: 
> > Hi, 
> > I am using sqlalchemy core. I want to generate select query with 
> > table_name.* option in select part when I am performing join and it 
> should 
> > be dialect specific.  In below query I am using below line of code. 
> > 
>
> This might not be what you want to do, but you can read all the column 
> names like this: 
>
> t = Table("step14", metadata, autoload_with=engine) 
>
> then "t" will have all the columns in step14 explicitly.  You can do: 
> select([t]). 
>
> maybe you want to avoid the expense of reflecting the table name. 
> here's a trick you can do: 
>
> from sqlalchemy import select, table, column 
> from sqlalchemy.sql import quoted_name 
>
> step14 = table("Step14", column(quoted_name('*', quote=False))) 
>
> stmt = select([step14.c['*']]).select_from(<your join>) 
>
> seems to work 
>
> >>> print(select([table("Step14", column(quoted_name('*', 
> quote=False))).c['*']])) 
> SELECT "Step14".* 
> FROM "Step14" 
>
> >>> print(select([table("Step14", column(quoted_name('*', 
> quote=False))).c['*']]).compile(dialect=mssql.dialect())) 
> SELECT [Step14].* 
> FROM [Step14] 
>
> though it looks like you are using an alias... 
>
> >>> print(select([table("Step1", column(quoted_name('*', 
> quote=False))).alias("Step14").c['*']]).compile(dialect=mssql.dialect())) 
> SELECT [Step14].* 
> FROM [Step1] AS [Step14] 
>
>
>
>
>
> > select(["*"]).select_from(join_obj). 
> > 
> > Mssql and Oracle dialect gives below query output 
> > 
> > MSSQL : 
> > SELECT  *  FROM [Step1] AS [Step14] JOIN [ORDERS] AS [ORDERS6] ON 
> > [Step14].[CUST_ID1] = [ORDERS6].[CUSTOMER_ID] 
> > ORACLE QUERY: 
> > SELECT * FROM "Step1" "Step14" JOIN "ORDERS" "ORDERS6" ON 
> > "Step14"."CUST_ID1" = "ORDERS6"."CUSTOMER_ID" 
> > above queries will return columns from both the tables. 
> > 
> > My requirement is query should be 
> > MSSQL : 
> > SELECT  [step14].*  FROM [Step1] AS [Step14] JOIN [ORDERS] AS [ORDERS6] 
> ON 
> > [Step14].[CUST_ID1] = [ORDERS6].[CUSTOMER_ID] 
> > ORACLE QUERY: 
> > SELECT "step14".* FROM "Step1" "Step14" JOIN "ORDERS" "ORDERS6" ON 
> > "Step14"."CUST_ID1" = "ORDERS6"."CUSTOMER_ID" 
> > 
> > Note: 
> > Its not possible to me get all columns from table which I want to 
> select. I 
> > will only get columns which used for join. So I cannot use column based 
> > select query. I have Littlebit tricky requirements in my project. 
> > 
> > -- 
> > SQLAlchemy - 
> > The Python SQL Toolkit and Object Relational Mapper 
> > 
> > http://www.sqlalchemy.org/ 
> > 
> > To post example code, please provide an MCVE: Minimal, Complete, and 
> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> > description. 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sqlalchemy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to sqlalchemy+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to