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() 

Comments

  1. Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
    sql server dba online training
    sql database administrator training

    ReplyDelete

Post a Comment

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

xcode - Swift Playground - Files are not readable -

windows - How to automate a file conversion xwm to mp3 with xwmaencode.exe using bat file -