Get Query Text from SqlAlchemy Select ObjectHow do I get a raw, compiled SQL query from a SQLAlchemy expression?SQLAlchemy - build query filter dynamically from dictSQLAlchemy Unique ObjectApplying LIMIT and OFFSET to all queries in SQLAlchemyProper way to prevent SQLAlchemy from re-running queries on expired objects?sqlalchemy: Controlling columns selected from querysqlalchemy, alchimia and create objects from raw queryHow to pretty format the printing of SQL Queries in SQLAlchemy?Flask and SQLAlchemy sort in display without new query?sqlalchemy, select objects that has all tags

How do I resolve science-based problems in my worldbuilding?

Why did the Bohr Model Successfully calculate some of the energy levels in hydrogen?

A question about the に in this sentence

Why is potassium ferrocyanide considered safe for consumption, when it is just one reaction away from the highly toxic potassium cyanide?

SD Card speed degrading and doesn't work on one of my cameras: can I do something?

Why use [FormalN]?

MS in Mathematics, having trouble finding work outside teaching algebra

Making Sandwiches

'Nuke the sky' to make a rocket launch a tiny bit easier

Polynomial Chebyshev Regression versus multi-linear regression

How to present boolean options along with selecting exactly 1 of them as "primary"?

Why are Democrats mostly focused on increasing healthcare spending, rarely mentioning any proposals for decreasing the costs of healthcare services?

A shoe in the safe

Need Good OOP Design For World and Countries Problem

Giving a talk on a different topic than what we discussed

How do the Martian rebels defeat Earth when they're grossly outnumbered and outgunned?

Speaking German abroad and feeling condescended to when people speak English back to me

Fivefold division of the whole tone - What does it mean?

Can you make monkeys human?

Can "marriage" be used as a verb?

What type of logical fallacy is the offering of a source which is really long and not specifying what part of the source is relevant?

Why does Smaug have 4 legs in the 1st movie but only 2 legs in the 2nd?

What is the meaning of Text inside of AMS logo

Are the EVA suits used in the ISS and in the NBL same or different?



Get Query Text from SqlAlchemy Select Object


How do I get a raw, compiled SQL query from a SQLAlchemy expression?SQLAlchemy - build query filter dynamically from dictSQLAlchemy Unique ObjectApplying LIMIT and OFFSET to all queries in SQLAlchemyProper way to prevent SQLAlchemy from re-running queries on expired objects?sqlalchemy: Controlling columns selected from querysqlalchemy, alchimia and create objects from raw queryHow to pretty format the printing of SQL Queries in SQLAlchemy?Flask and SQLAlchemy sort in display without new query?sqlalchemy, select objects that has all tags






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















When I build a SqlAlchemy Select object with sqlalchemy, what is the best way to get the query text from the object?



I have been calling



compile(compile_kwargs='literal_binds': True).string



on the query object -- that is,



qry_object.compile(compile_kwargs='literal_binds': True).string)



but this surely is not the best way.



Have looked in the SqlAlchemy docs and code but haven't found the right way.



More elaborated example:



from sqlalchemy import select

class MyTable(Base):
__tablename__ = 'my_table'

... some fields ...


qry_object = select(["*"], from_obj=MyTable)

self.assertSqlFormatEqual(
qry_object.compile(compile_kwargs='literal_binds': True).string,
''SELECT * FROM file_receipt')









share|improve this question
































    0

















    When I build a SqlAlchemy Select object with sqlalchemy, what is the best way to get the query text from the object?



    I have been calling



    compile(compile_kwargs='literal_binds': True).string



    on the query object -- that is,



    qry_object.compile(compile_kwargs='literal_binds': True).string)



    but this surely is not the best way.



    Have looked in the SqlAlchemy docs and code but haven't found the right way.



    More elaborated example:



    from sqlalchemy import select

    class MyTable(Base):
    __tablename__ = 'my_table'

    ... some fields ...


    qry_object = select(["*"], from_obj=MyTable)

    self.assertSqlFormatEqual(
    qry_object.compile(compile_kwargs='literal_binds': True).string,
    ''SELECT * FROM file_receipt')









    share|improve this question




























      0












      0








      0








      When I build a SqlAlchemy Select object with sqlalchemy, what is the best way to get the query text from the object?



      I have been calling



      compile(compile_kwargs='literal_binds': True).string



      on the query object -- that is,



      qry_object.compile(compile_kwargs='literal_binds': True).string)



      but this surely is not the best way.



      Have looked in the SqlAlchemy docs and code but haven't found the right way.



      More elaborated example:



      from sqlalchemy import select

      class MyTable(Base):
      __tablename__ = 'my_table'

      ... some fields ...


      qry_object = select(["*"], from_obj=MyTable)

      self.assertSqlFormatEqual(
      qry_object.compile(compile_kwargs='literal_binds': True).string,
      ''SELECT * FROM file_receipt')









      share|improve this question















      When I build a SqlAlchemy Select object with sqlalchemy, what is the best way to get the query text from the object?



      I have been calling



      compile(compile_kwargs='literal_binds': True).string



      on the query object -- that is,



      qry_object.compile(compile_kwargs='literal_binds': True).string)



      but this surely is not the best way.



      Have looked in the SqlAlchemy docs and code but haven't found the right way.



      More elaborated example:



      from sqlalchemy import select

      class MyTable(Base):
      __tablename__ = 'my_table'

      ... some fields ...


      qry_object = select(["*"], from_obj=MyTable)

      self.assertSqlFormatEqual(
      qry_object.compile(compile_kwargs='literal_binds': True).string,
      ''SELECT * FROM file_receipt')






      python-3.x sqlalchemy






      share|improve this question














      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 21:20









      tlskrtlskr

      243 bronze badges




      243 bronze badges

























          0






          active

          oldest

          votes













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407014%2fget-query-text-from-sqlalchemy-select-object%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown


























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407014%2fget-query-text-from-sqlalchemy-select-object%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown









          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript