In sqlalchemy, how can I use polymorphic joined table inheritance when the child table has multiple foreign keys to the parent table?


OutOfBrain
HOME ยป Databases

I have a parent table called pbx_point that has a point_type column. I also have a child table called pbx_route, with a column called point_id pointing back to pbx_point.


I'd like to use sqlalchemy's joined table inheritance to relate these two tables via declarative base, and use polymorphic inheritance


This works fine - or rather, it would, if not for the following additional constraint: pbx_point also has a foreign key called initial_route_id pointing to pbx_route.


I'm also using reflection below, but the db is as I describ


Related to : In sqlalchemy, how can I use polymorphic joined table inheritance when the child table has multiple foreign keys to the parent table?
In sqlalchemy, how can I use polymorphic joined table inheritance when the child table has multiple foreign keys to the parent table?
Databases

I have a parent table called pbx_point that has a point_type column. I also have a child table called pbx_route, with a column called point_id pointing back to pbx_point.


I'd like to use sqlalchemy's joined table inheritance to relate these two tables via declarative base, and use polymorphic inheritance


This works fine - or rather, it would, if not for the following additional constraint: pbx_point also has a foreign key called initial_route_id pointing to pbx_route.


I'm also using reflection below, but the db is as I describ

How do I create a child class from a parent class in SQLAlchemy's Joined Table Inheritance?
Databases

I'm developing a small database where there are far more People than Users, so currently have the following Model.


class Person(db.Model):
__tablename__ = 'people'
id = db.Column(db.Integer, primary_key = True)
forename = db.Column(db.String(64))
surname = db.Column(db.String(64))
memberships = db.relationship('Membership', backref='person')
@property
def name(self):
return self.forename + ' ' + self.surname
def __repr__(self):
return '<Person %r %r>' % (self.forename, self.surname)
class User(Person):
__tablename__ = 'users'
sqlite: No such table found(parent table) error while creating foreign key in child table
Databases

I have created one Member_Master table whose primary key is member_id in sqlite manager for android and creating foreign key in child table e.g Event_Master for member_id from Member_Master. I was getting no such table found:Member_Master error
But now I am getting the following error :


SQLiteManager: CREATE TABLE "main"."Events_Master" ("event_id" NUMERIC PRIMARY KEY NOT
NULL ,"event_name" TEXT NOT NULL ,"event_details" TEXT NOT NULL ,"event_start_date"
DATETIME NOT NULL ,"event_end_date" DATETIME NOT NULL ,"event_time" DATETIME NOT NULL
,"event_venue" TEXT NOT NULL ,"min_level" NUMERIC,"status_id" NUMERIC,"member_id"
SQLAlchemy: Multiple foreign keys to same table with compound primary key
Databases

In SQLAlchemy, imagine we have a table Foo with a compound primary key, and Bar, which has two foreign key constrains linking it to Foo (each Bar has two Foo objects).


My problem is with the relationship function, which makes me repeat the information (in the primaryjoin) which I have already given in the ForeightKeyConstraint (violating DRY). Is there some other way of structuring this so that I don't have to repeat information? Some way of passing the relevant ForeignKeyConstraint to relationship?


class Foo(Base):


HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .