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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:52:59+00:00 2026-06-07T13:52:59+00:00

I have a second database in my Django application, which is filled with static

  • 0

I have a second database in my Django application, which is filled with static data about the equivalent of zipcodes in my country (Brazil) and the related streets, neighborhoods, cities and states.

I’m trying to access it like this:

from django.db import connections
from django.conf import settings

try:
    cursor = connections[settings.CEP_DATABASE_NAME].cursor()
    ....

but I get the following Error:

OperationalError: (1049, "Unknown database 'cep'")

My settings.py:

CEP_DATABASE_NAME = 'cep'
DATABASES = {
    'default': {
        'NAME': 'hypersaber',
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST' : 'localhost',
        'PORT' : '3306',
        'OPTIONS' : {"init_command": "SET storage_engine=INNODB"}
    },
    CEP_DATABASE_NAME: {
        'NAME': CEP_DATABASE_NAME,
        'ENGINE': 'django.db.backends.mysql',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST' : 'localhost',
        'PORT' : '3306',
        'OPTIONS' : {"init_command": "SET storage_engine=INNODB"}
    }
}

Both my MySQL DB instances are up and running.

Am I missing some configuration?

Thanks in advance.

  • 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-07T13:53:01+00:00Added an answer on June 7, 2026 at 1:53 pm

    Your code looks fine to me.

    I have to ask the obvious: Does that database actually exist on localhost?

    That’s an exception thrown from the MySQLdb module, which makes me think there’s nothing django-specific going wrong here and is why I ask if it’s just a real, low-level error.

    Can you access the database from a regular (non django) python script?

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

Sidebar

Related Questions

I have an Android MapView in which i need to have a second layer
Im developing a web application in a maven project. I also have a second
I have written a simple feedback application in django. It's not particulairly complex, basically
Hi i am using django 1.2 .I my case i have few models which
I'm modeling a database relationship in django, and I'd like to have other opinions.
I'm new to Django and have only been using sqlite3 as a database engine
I have a working django-admin custom command that I use to populate my database
I currently have a database call which works in one area, but not another.
I have a task of copying the data from one database to another.I don't
hopefully someone can help me with this odd problem. I have a database which

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.