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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:11:11+00:00 2026-06-05T13:11:11+00:00

I am creating a connection instance before the start of the application # app.py

  • 0

I am creating a connection instance before the start of the application

# app.py
mongodb_conn = pymongo.Connection(host=host, port=int(port), safe=True)

print(mongodb_conn) # Connection('127.0.0.1', 27017)

...

bottle.run(...)

But, then in my requests, when I try to access this connection from other modules, it errs saying that mongodb_conn is None

# user.py
from app import mongodb_conn
...

db = mongodb_conn['somedb'] # TypeError: 'NoneType' object is not subscriptable

Can someone explain what’s going on?

  • 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-05T13:11:12+00:00Added an answer on June 5, 2026 at 1:11 pm

    Ok, I have been able to solve the problem. It was related to some discrepancies in module loading orders.

    But, it is perfectly alright to cache ONE connection instance and then use it for the entire lifetime of the application. And this is true even for threaded applications.

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

Sidebar

Related Questions

I'm creating a VB2010 application which will require a connection to MSSQL. Should I
I am creating a simple WPF Application with a Sql Connection. The problem is
I'm creating a multithread chat client server application. In the server connection I use
I am creating a Connection object and making jdbc connection in a constructor of
I have MSSQLServer 2005 installed on my machine. I am creating a connection string
I am creating a JDBC connection pool resource for GlassFish, using the server's Admin
I have been creating a peer to peer connection for a new game, that
Is there a difference in manually creating your (let's say db connection string) in
I've recently refactored my application with the following: Linq to SQL db connection Objects
I have had difficulty creating a connection string in c# that will connect to

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.