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

  • SEARCH
  • Home
  • 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 6853105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:28:17+00:00 2026-05-27T01:28:17+00:00

I am working on some reports (counts) and I have to fetch counts for

  • 0

I am working on some reports (counts) and I have to fetch counts for different parameters. Pretty simple but tedious.

A sample query for one parameter :

qCountsEmployee = (
    "select count(*) from %s where EmployeeName is not null"
     % (tablename)
     )
CountsEmployee = execute_query(qCountsEmployee)

Now I have few hundred such parameters!

What I did was : create a list of all the parameters and generate them using a quick Python script and then copy that text and put it in the main script to avoid the tedious lines.

columnList = ['a', 'b', ............'zzzz']

for each in columnList:
   print (
            'q' + each + ' ='
            + '"select count(*) from %s where' + each
            + 'is not null" % (tablename)'
         )
   print each + '   = execute_query(' + 'q' + each + ')'

While this approach works, I was wondering if instead of a separate script to generate lines of code and copy paste into main program, can I generate them in the main script directly and let the script treat them as lines of code? That will make the code much more readable is what I think. Hope I made sense! Thank you…

  • 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-05-27T01:28:18+00:00Added an answer on May 27, 2026 at 1:28 am

    It would be possible, but is not useful here.

    Just do something like

    columnList = ['a', 'b', ............'zzzz']
    
    results = {}
    for column in columnList:
        query = (
                "select count(*) from " + tablename
                + " where " + column + " is not null"
                )
        result = execute_query(qCountsEmployee)
        results[column] = result
    

    You as well can put all this together in a generator function and do

    def do_counting(column_list):
        for column in column_list:
            query = (
                "select count(*) from " + tablename
                + " where " + column + " is not null"
                )
            result = execute_query(qCountsEmployee)
            yield column, result
    
    result_dict = dict(do_counting(['...']))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some working reports that must be deployed on SSRS. One more customization
I have been working in SSRS 2008 r2 to produce some complex reports. it
I'm working on some reports in SSRS 2005. I have a bit of experience
I'm passing some parameters to a CR report programatically and it was working fine,
I have some working code with a crutch to add BOM marker to a
I am working on some SSRS reports and am running into an issue where
I am working on Android database type application. We need to show some reports.
I notice in some Velocity reports I'm working with that $fn contains some built
I am wanting to upgrade some copies of SAP Crystal Reports. I am working
I have a file where I am showing two different reports. So these two

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.