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

The Archive Base Latest Questions

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

So I recently changed from sqlite to postgres so that I could push my

  • 0

So I recently changed from sqlite to postgres so that I could push my site to heroku. The issue I am having is that the tables are now getting built out of order??

class Data(Base):
    __tablename__ = 'data'
    id = Column(Integer, autoincrement=True, primary_key=True)
    data_type = Column(Integer, primary_key=True, unique=True)
    value = Column(Text, primary_key=True, unique=True)
    range_lower = Column(Integer)
    range_upper = Column(Integer)
    gold = Column(Boolean)

    def __init__(self, data_type, value, range_lower=0, range_upper=0, gold=False):
        self.data_type = data_type
        self.value = value
        self.range_lower = range_lower
        self.range_upper = range_upper
        self.gold = gold




class Page(Base):
    __tablename__ = 'page'
    id = Column(Integer, autoincrement=True, primary_key=True)
    data_type = Column(Integer, ForeignKey('data.data_type'))
    description = Column(Text)
    annotations_per_page = Column(Integer)
    uses_gold = Column(Boolean)

    def __init__(self, data_type, description='default description', annotations_per_page=1, uses_gold=False):
        self.data_type = data_type
        self.description = description
        self.annotations_per_page = annotations_per_page
        self.uses_gold = uses_gold

The issue I am having is that sqlalchemy/pyramid or whatever the populate script generated by python setup.py develop on one of these types of projects, is trying to create the table Page before the table Data. Since there are foreign keys in Page that depend on Table, this is failing. I can’t find any mention of this issue in the documentation, any insight would be greatly appreciated.

-Sam

  • 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-05T04:50:52+00:00Added an answer on June 5, 2026 at 4:50 am

    you need to use database metadata

    and these functions
    metadata =MetaData()
    creat_all()

    it generates the tables in order of their dependency.

    ref:http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html

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

Sidebar

Related Questions

I have a form on an ASP.NET MVC site which I've recently changed from
A WordPress site has recently changed from .co.uk to .org. As soon as this
I have recently changed to ubuntu from windows and am having difficulty with the
I've recently changed my schema a bit so my classes inherit from a super
I was trying to update the Recently Changed App by adding the columns that
I have a pretty complex PHP/HTML view. However, I recently changed my site to
In our C# code I recently changed a line from inside a linq-to-sql select
I've recently started working with PHP and SQLite and I'm having problems with PHP
I recently changed from 1.0 to 1.1 without making any changes to the theme
I have recently changed from using the cassini development server to IIS 7.5 express,

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.