sql - SQLAlchemy : FOR XML PATH equivalent -
how put column containing multiple rows in xml tag?
here sample mssql code snippet,
(select description wev_sty ps with(nolock) join moee_pov_sty mps with(nolock) on ps.sty_cd = mps.prv_sty_cd xml path('')) ppb_sdd what sqlalchemy equivalent above query? how translate for xml path(' ') sqlalchemy?
you can execute raw sql query in sqlalchemy. based on sqlalchemy doc , this, try like:
# pymssql engine = create_engine('mssql+pymssql://scott:tiger@hostname:port/dbname') raw_con = engine.raw_connection() try: cursor = raw_con.cursor() # add proper sql code here cursor.execute('(select description wev_sty ps with(nolock) join moee_pov_sty mps with(nolock) on ps.sty_cd = mps.prv_sty_cd xml path('')) ppb_sdd;') results = cursor.fetchall() cursor.close() finally: raw_con.close()
Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
ReplyDeletesql server dba online training
sql database administrator training