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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:16:18+00:00 2026-06-08T00:16:18+00:00

For same code snippet, SQLAlchemy creates Foreign Key constraint on Mac OX, however, it

  • 0

For same code snippet, SQLAlchemy creates Foreign Key constraint on Mac OX, however, it fails to create foreign key constraint on Debian Linux.

Environment & Libraries:

Python 2.7

SQLAlchemy 0.7.8

MySQL-python-1.2.3 [This is the connector, and I am suspecting something is wrong here]

Code Snippet:

class PRStatusCV(globalBase):

    __tablename__ = 'pr_status_cv'
    pr_status_cv_id = Column(Integer, primary_key=True)
    name            = Column(VARCHAR(100), nullable=False, unique=True)

    def __init__(self, id, name, desc):
        self.pr_status_cv_id = id
        self.name            = name
        self.description     = desc



class PhysicalRun(globalBase):

    __tablename__ = 'prs'
    pr_id       = Column(Integer, primary_key=True)
    run_name              = Column(VARCHAR(200), nullable=False, unique=True)
    pr_status_cv_id       = Column(Integer, ForeignKey('pr_status_cv.pr_status_cv_id'))

    def __init__(self, name, status):
        self.run_name              = name
        self.pr_status_cv_id       = status

In Debian Linux, the table created contains:

CREATE TABLE `prs` (
  `pr_id` int(11) NOT NULL AUTO_INCREMENT,
  `run_name` varchar(200) NOT NULL,
  `pr_status_cv_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`pr_id`),
  UNIQUE KEY `run_name` (`run_name`),
  KEY `pr_status_cv_id` (`pr_status_cv_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 | 

In Mac OSX the table created looks like this:

CREATE TABLE `prs` (
  `pr_id` int(11) NOT NULL AUTO_INCREMENT,
  `run_name` varchar(200) NOT NULL,
  `pr_status_cv_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`pr_id`),
  UNIQUE KEY `run_name` (`run_name`),
  KEY `pr_status_cv_id` (`pr_status_cv_id`),
  CONSTRAINT `prs_ibfk_1` FOREIGN KEY (`pr_status_cv_id`) REFERENCES `pr_status_cv` (`pr_status_cv_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Observation:
Seems like for Mac OSX SQLAlchemy chose InnoDB DB Engine by default, and MyISAM is chosen for Debian. Any idea why this is happening so?

What modifications do I need to make to have constraint – CONSTRAINT `prs_ibfk_1` FOREIGN KEY (`pr_status_cv_id`) REFERENCES `pr_status_cv`, instead of just KEY `pr_status_cv_id` (`pr_status_cv_id`)?

Is anything incorrect with my Debian Python deploy?

  • 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-08T00:16:20+00:00Added an answer on June 8, 2026 at 12:16 am

    ENGINE=MyISAM MyISAM dosn’t have Foreign Keys

    add __table_args__ = {'mysql_engine':'InnoDB'} to get InnoDB insted

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

Sidebar

Related Questions

In an Alexander Kuznetsov article , he presents the follow code snippet: CREATE TABLE
Is it necessary to lock code snippet where multiple threads access same wpf component
For the same code, Eclipse shows warnings about unused variables, but compiling with javac
Take the same code that sits on nodejs.org home page. Serve a static file
Does anybody know why the same code from this page http://emacsformacosx.com/ would not render
I've got another problem in the same code... I'm getting this error: initialization method
We are running multiple domains through the same code and we want to save
I would like to use the same code for copying files to an FTP
I am using JQGrid I have it on 2 domains (same code)... On domain
Casus: How to edit and advance with the same code, from several distanced locations

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.