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;
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
add a comment |
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
1
that doesn't work?
– SuperStew
Mar 27 at 17:24
add a comment |
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
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
python sqlite
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
that doesn't work?
– SuperStew
Mar 27 at 17:24