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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:07:28+00:00 2026-05-23T21:07:28+00:00

I am trying to create a test database that is a replica of a

  • 0

I am trying to create a test database that is a replica of a preexisting database. I am using Django models (theoretically the models used with the original database) in order to do this. I recently inherited the code from someone else and am trying to figure out what exactly is going on with the code.

In the model, one the of the tables has two columns identified as the primary key.

        column1 = models.IntegerField(primary_key = True)
        column2 = models.IntegerField(primary_key = True)
        column3 = models.CharField(max_length = 30)

When I try to sync this model to the test database – an error occurs :

File “/somePathHere/MySQLdb/connections.py”, line 36, in defaulterrorhandler raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1068, ‘Multiple primary key defined’)

It is written in the django docs that Django does not allow multiple primary keys. However, looking at the output of DESCRIBE [tablename] in the original MySQL database, it seems like that is exactly what is going on here :

        +------------+------------+------+-----+---------+-------+
        | Field      | Type       | Null | Key | Default | Extra |
        +------------+------------+------+-----+---------+-------+
        | IDENTIFIER | bigint(20) | NO   | PRI | NULL    |       |
        | TIMESTAMP_ | bigint(20) | NO   | PRI | NULL    |       |
        | VALUE_     | longtext   | YES  |     | NULL    |       |
        +------------+------------+------+-----+---------+-------+

Note that both IDENTIFIER and TIMESTAMP_ are listed as the primary keys.

I’m seeing a lot of topics on SO ( Example 1 , Example 2, and Example 3 ) about creating a primary key based on multiple columns – is what I am seeing a composite key? In which case, how is this relayed via a Django model, i.e. how would one replicate it?

If it is not a composite key, what is it?

  • 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-23T21:07:29+00:00Added an answer on May 23, 2026 at 9:07 pm

    It’s a composite primary key. Try executing this:

    show create table mytable;
    

    It should show you the definition of the composite key.

    This is nothing “unusual” from a mysql perspective.

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

Sidebar

Related Questions

I am trying to create a unit test for a method that takes a
I'm trying to create a JQuery function that will test a string for the
I'm trying to create a key like this _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\') and the key
RSpec newbie here. I'm trying to test my models, which have methods that uses
I'm trying to write a unit test for the database layer that validates the
I have this weird issue. I am trying to create a service that synchs
I'm trying to create a database that contains mock objects for testing purposes. I'd
I'm trying to create some Functional tests for a Django app that uses South
I am trying to create a go-moku game using jquery,php, and mysql database. I
I am trying to create a test harness for our QA staff to test

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.