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 6767827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:59:51+00:00 2026-05-26T14:59:51+00:00

Based on couple of Api Calls I have constructed the following data structure (Dictionary).

  • 0

Based on couple of Api Calls I have constructed the following data structure (Dictionary). I have used python dictionary as a holding place.

325167 A,
953929 B, A, C
824420 D, B,
796992 K, M, Z,
825116 J, F, E,

I take the each value, and send a query to the database and get a results set select something from some_table where some_table.someCol = ‘A’. Then I am trying to save this data in another dictionary to use it in future.

This is the error I am currently trying to deal, cl_to is the column name of the query that focusing.

Traceback (most recent call last):
  File "Category.py", line 148, in <module>
    categoryResults.append(categoryRow['cl_to']);
TypeError: 'NoneType' object is not subscriptable
{'cl_to': 'EP-plater_etter_\xc3\xa5r'}
{'cl_to': 'Musikk_i_2002'}
None

This is how my code looks like:

#Dictionary to save initial category with the rest of cl_to
baseCategoryTree = {}
categoryResults = []

# query get all the categories a category is linked to
categoryQuery = "select cl_to from sometable cl left join anotherTable p on cl.cl_from = p.another_column where p.some_column=14 and p.another_column ='";
cursor = db.cursor(cursors.SSDictCursor);

    for key, value in idTitleDictionary.iteritems():
        for startCategory in value[0]:
            #print startCategory + "End of Query";
            try:
                baseCategoryTree[startCategory] = [];
                #print categoryQuery + startCategory;
                cursor.execute(categoryQuery + startCategory + "'");
                done = False;
                while not done:
                    categoryRow = cursor.fetchone();
                    print categoryRow;
                    if not categoryRow:
                        done = True;
                        continue;
                categoryResults.append(categoryRow['cl_to']);
                baseCategoryTree[startCategory].append(categoryResults);
            except Exception, e:
                traceback.print_exc();

Best;
N-H

  • 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-26T14:59:52+00:00Added an answer on May 26, 2026 at 2:59 pm

    …

                while not done:
                    categoryRow = cursor.fetchone();
                    print categoryRow;
                    if not categoryRow:
                        done = True;
                        continue;
                categoryResults.append(categoryRow['cl_to']);
    

    …

    continue will wrap to the while above it at which point categoryRow is going to be None.

    Then when:

     categoryRow['cl_to'] 
    

    is encountered… boom.

    You probably want the following if you want to capture all rows:

    …

                while not done:
                    categoryRow = cursor.fetchone();
                    print categoryRow;
                    if not categoryRow:
                        done = True;
                        continue;
                    categoryResults.append(categoryRow['cl_to']);
    

    …

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

Sidebar

Related Questions

I have couple of questions: What is exactly VJoyD used for? Based on my
Update: Based on a couple of the answers I have received, I just want
I have a structure of base class and a couple of inherited classed. Base
I have done a couple of simple swing based apps with static layout, but
I have a couple of questions regarding a modular GWT based application framework. I
I have a WCF REST service that exposes a couple dozen objects and based
We have couple of MS based web-services, visible as .asmx?WSDL links in intranet. There
I have a couple of personal web-based projects in the pipeline, and am unable
I have couple of questions that about mixing code: a complete project based on
I have a page which has a couple option links that set GET-based parameters

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.