• Aw: Re: Re: mypy question

    From Karsten Hilbert@3:633/280.2 to All on Sun Dec 31 04: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

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Karsten Hilbert@3:633/280.2 to All on Sun Dec 31 04: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 string=
    s
    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

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)