Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:20:23+00:00 2026-06-15T09:20:23+00:00

So I have a database with 10 fields(call them a, b, c….j), and I

  • 0

So I have a database with 10 fields(call them a, b, c….j), and I need to create a function “find_use()” that can find and modify records in the database based on any combination of fields given to it as arguments ( ie: find_use(a==”happy”, g ==”birthday”) ). Also, due to privileges, I am not generating the SQL queries directly, but instead use an SQL wrapper the system provides called “selector()” which will locate records based on the same arguments, ie: query = selector(a==”happy”, g==”birthday”), which would then return a list of the matching records

So the problem is, since I don’t know what arguments find_use() will be receiving, I don’t know how to structure the inner call to selector(). Ideally, the call to selector should be created dynamically; something to the effect of:

def find_use(a='',b='',c='',.....j=''):
   vars = locals()
   for v in vars:
      if v.value() != '':
        q_string += '{0} == {1},'.format(v.key(),v.value())
   query = selector(q_string) 
   ...do something to query...

This, however, will not work since selector does not take a string, but rather arguments in the same format as the find_use() function. How, then, can this be done. I have the feeling this is actually really easy, and I’m just missing something obvious. Any input would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:20:24+00:00Added an answer on June 15, 2026 at 9:20 am

    I think you are looking for keyword argument unpacking:

    def find_use(**kwargs):
       query = selector(**kwargs) 
       ...do something to query...
    

    When defined this way, find_use can receive an arbitrary number of keyword arguments. The keyword arguments are collected in a dict, kwargs.

    For example,

    def foo(**kwargs):
        print(kwargs)    
    foo(a = 'happy', g = 'birthday')
    

    yields

    {'a': 'happy', 'g': 'birthday'}
    

    and if

    def bar(a, g):
        print(a)
        print(g)
    

    then

    bar(**{'a': 'happy', 'g': 'birthday'})  # like selector(**kwargs)
    

    yields

    happy
    birthday
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two MySQL database that contain two table, let's call them TABLE_A and
My problem is that the database fields have been badly designed by previous people
I have a database full of text fields that look like this: (paragraph of
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a database with thousands of entries, that have two date/time fields, let's
I have a domain class containing a couple of fields. I can access them
I have a function that takes object instances and reduces them down to an
I have a Database with this fields: Firstname, Lastname, picture. I have a gtk.Label
In my database we have fields where the data is not readable. I now
I have a Database named CarsType.accdb there are four fields in the data base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.