Return records for 100 specific surnamesandroid sqlite delete arraylistHow do I return multiple values from a function?How to set Sqlite3 to be case insensitive when string comparing?Proper way to declare custom exceptions in modern Python?Peak detection in a 2D arrayInstalling specific package versions with pipUnderstanding the map function“Large data” work flows using pandasIOS Sqlite Database - Retriving batch by batch recordsHow to return two elements with same indexes from different tuples?Query is unable to match parts after “/” or parts within “()” in the data

Would it be possible to have a GMO that produces chocolate?

Is a player able to change alignment midway through an adventure?

Did the British navy fail to take into account the ballistics correction due to Coriolis force during WW1 Falkland Islands battle?

Sun setting in East!

What is the history of the university asylum law?

Was Switzerland really impossible to invade during WW2?

How do I request a longer than normal leave of absence period for my wedding?

How much code would a codegolf golf if a codegolf could golf code?

What is the difference between true neutral and unaligned?

Does norwegian.no airline overbook flights?

Is “I am getting married with my sister” ambiguous?

Sleeping solo in a double sleeping bag

Was there ever a treaty between 2 entities with significantly different translations to the detriment of one party?

Can you feel passing through the sound barrier in an F-16?

Confirming resignation after resignation letter ripped up

What are some interesting features that are common cross-linguistically but don't exist in English?

Justifying the use of directed energy weapons

How is the list of apps allowed to install another apps populated?

Earth rotation discrepancy

How do applicants for an NSF fellowship come up with a research plan for the research statement part of the applications

How would one country purchase another?

Is it safe to remove the bottom chords of a series of garage roof trusses?

Are there account age or level requirements for obtaining special research?

Why were movies shot on film shot at 24 frames per second?



Return records for 100 specific surnames


android sqlite delete arraylistHow do I return multiple values from a function?How to set Sqlite3 to be case insensitive when string comparing?Proper way to declare custom exceptions in modern Python?Peak detection in a 2D arrayInstalling specific package versions with pipUnderstanding the map function“Large data” work flows using pandasIOS Sqlite Database - Retriving batch by batch recordsHow to return two elements with same indexes from different tuples?Query is unable to match parts after “/” or parts within “()” in the data






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








0















I have a tuple, l, with 100 surnames. How can I do something like this in sqlite3:



l = ("Smith", "Murphy", "Owens", ...)
with sqlite3.connect("census.sqlite") as conn:
c = conn.cursor()
c.execute('select firstname, surname from census_data where surname in ?',(l,))


so that I can return all the records for the surnames contained in l.










share|improve this question





















  • 1





    that doesn't work?

    – SuperStew
    Mar 27 at 17:24


















0















I have a tuple, l, with 100 surnames. How can I do something like this in sqlite3:



l = ("Smith", "Murphy", "Owens", ...)
with sqlite3.connect("census.sqlite") as conn:
c = conn.cursor()
c.execute('select firstname, surname from census_data where surname in ?',(l,))


so that I can return all the records for the surnames contained in l.










share|improve this question





















  • 1





    that doesn't work?

    – SuperStew
    Mar 27 at 17:24














0












0








0








I have a tuple, l, with 100 surnames. How can I do something like this in sqlite3:



l = ("Smith", "Murphy", "Owens", ...)
with sqlite3.connect("census.sqlite") as conn:
c = conn.cursor()
c.execute('select firstname, surname from census_data where surname in ?',(l,))


so that I can return all the records for the surnames contained in l.










share|improve this question
















I have a tuple, l, with 100 surnames. How can I do something like this in sqlite3:



l = ("Smith", "Murphy", "Owens", ...)
with sqlite3.connect("census.sqlite") as conn:
c = conn.cursor()
c.execute('select firstname, surname from census_data where surname in ?',(l,))


so that I can return all the records for the surnames contained in l.







python sqlite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 16:46







Baz

















asked Mar 27 at 16:41









BazBaz

2,02528 gold badges89 silver badges205 bronze badges




2,02528 gold badges89 silver badges205 bronze badges










  • 1





    that doesn't work?

    – SuperStew
    Mar 27 at 17:24













  • 1





    that doesn't work?

    – SuperStew
    Mar 27 at 17:24








1




1





that doesn't work?

– SuperStew
Mar 27 at 17:24






that doesn't work?

– SuperStew
Mar 27 at 17:24













1 Answer
1






active

oldest

votes


















2
















Question: return all the records for the surnames contained in a tuple




The core is, create a Query with as much bindings - ? - as in the sequence.

The [:-1] is needed to exclude the last comma ...?,.




  • SQL As Understood By SQLite - whereclause



    surnames = ("Smith", "Murphy", "Owens")
    bindings = '?,'*len(surnames)
    QUERY = "select firstname, surname from census_data where surname in ();"
    .format(bindings[:-1])
    print(QUERY)
    # >>> select firstname, surname from census_data where surname in (?,?,?);
    cur.execute (QUERY, surnames)


Tested with Python:3.5.3 - sqlite3:2.6.0






share|improve this answer


























    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/3.0/"u003ecc by-sa 3.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%2f55382411%2freturn-records-for-100-specific-surnames%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2
















    Question: return all the records for the surnames contained in a tuple




    The core is, create a Query with as much bindings - ? - as in the sequence.

    The [:-1] is needed to exclude the last comma ...?,.




    • SQL As Understood By SQLite - whereclause



      surnames = ("Smith", "Murphy", "Owens")
      bindings = '?,'*len(surnames)
      QUERY = "select firstname, surname from census_data where surname in ();"
      .format(bindings[:-1])
      print(QUERY)
      # >>> select firstname, surname from census_data where surname in (?,?,?);
      cur.execute (QUERY, surnames)


    Tested with Python:3.5.3 - sqlite3:2.6.0






    share|improve this answer































      2
















      Question: return all the records for the surnames contained in a tuple




      The core is, create a Query with as much bindings - ? - as in the sequence.

      The [:-1] is needed to exclude the last comma ...?,.




      • SQL As Understood By SQLite - whereclause



        surnames = ("Smith", "Murphy", "Owens")
        bindings = '?,'*len(surnames)
        QUERY = "select firstname, surname from census_data where surname in ();"
        .format(bindings[:-1])
        print(QUERY)
        # >>> select firstname, surname from census_data where surname in (?,?,?);
        cur.execute (QUERY, surnames)


      Tested with Python:3.5.3 - sqlite3:2.6.0






      share|improve this answer





























        2














        2










        2










        Question: return all the records for the surnames contained in a tuple




        The core is, create a Query with as much bindings - ? - as in the sequence.

        The [:-1] is needed to exclude the last comma ...?,.




        • SQL As Understood By SQLite - whereclause



          surnames = ("Smith", "Murphy", "Owens")
          bindings = '?,'*len(surnames)
          QUERY = "select firstname, surname from census_data where surname in ();"
          .format(bindings[:-1])
          print(QUERY)
          # >>> select firstname, surname from census_data where surname in (?,?,?);
          cur.execute (QUERY, surnames)


        Tested with Python:3.5.3 - sqlite3:2.6.0






        share|improve this answer
















        Question: return all the records for the surnames contained in a tuple




        The core is, create a Query with as much bindings - ? - as in the sequence.

        The [:-1] is needed to exclude the last comma ...?,.




        • SQL As Understood By SQLite - whereclause



          surnames = ("Smith", "Murphy", "Owens")
          bindings = '?,'*len(surnames)
          QUERY = "select firstname, surname from census_data where surname in ();"
          .format(bindings[:-1])
          print(QUERY)
          # >>> select firstname, surname from census_data where surname in (?,?,?);
          cur.execute (QUERY, surnames)


        Tested with Python:3.5.3 - sqlite3:2.6.0







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 28 at 8:24

























        answered Mar 27 at 17:33









        stovflstovfl

        9,0405 gold badges12 silver badges36 bronze badges




        9,0405 gold badges12 silver badges36 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            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%2f55382411%2freturn-records-for-100-specific-surnames%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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현