• Aw: Re: Re: mypy question

    From Karsten Hilbert@21:1/5 to All on Sat Dec 30 18:08:08 2023
    It occurs to me that you could simplify things if you converted those
    plain query strings to dicts:

    'SELECT 1' --> {'SQL': 'SELECT 1'}

    Ha, indeed. There's likely not that many "simple string SQL queries"
    in that codebase so I shall take it as an opportunity to refactor them.

    So, at least that much good has come from the mypy hint ;-)

    Karsten

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karsten Hilbert@21:1/5 to All on Sat Dec 30 18:19:32 2023
    I'm fairly sure your database queries don't actually give you strings or dicts, right? You probably get lists (or iterators) of tuples and
    somewhere you convert them to the arguments you are feeding to
    run_queries().

    Ah, no, those queries are enshrined within the middleware as Python strings with placeholdders. When in need of being run they are assembled into
    a list of dicts-enriched-with-arguments-per-query (and fed to run_queries()).

    As to what queries *give* me: I have set up psycopg2 to, indeed, hand
    me a list of dicts (DictRow instances, that is). Those are then used
    in display rather than being fed to run_queries().

    Karsten

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)