Looking at the code, I dont know what:
ForeignKey('')
means, I guess that means you don't know which table to refer towards?
if batmon/radmon/deported are B, C, and D, and "Sensor" is not part of
the problem, just make them FK's to"Device"? Here's that
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.declarative import declared_attr
Model = declarative_base()
class Device(Model):
__tablename__ = 'device'
id = Column(Integer, primary_key=True)
type = Column(String(30), unique=False, nullable=False)
variant = Column(String(30), unique=False, nullable=True)
serialNo = Column(String(30), unique=True, nullable=False)
batmonConf = relationship('Batmon', backref='device',
uselist=False, lazy=True)
radmonConf = relationship('Radmon', backref='device',
uselist=False, lazy=True)
deportedConf = relationship('Deported', backref='device',
uselist=False, lazy=True)
class Batmon(Model):
__tablename__ = 'batmon'
id = Column(Integer, ForeignKey('
device.id'), primary_key=True)
voltage = Column(Integer, unique=False, nullable=False)
fet1 = Column(String(20), ForeignKey(''), unique=True)
fet2 = Column(String(20), unique=True, nullable=True)
pin = Column(String(20), unique=True, nullable=True)
mem1 = Column(String(20), unique=True, nullable=True)
mem2 = Column(String(20), unique=True, nullable=True)
class Radmon(Model):
__tablename__ = 'radmon'
id = Column(Integer, ForeignKey('
device.id'), primary_key=True)
fet1 = Column(String(20), unique=True, nullable=True)
fet2 = Column(String(20), unique=True, nullable=True)
pin = Column(String(20), unique=True, nullable=True)
mem1 = Column(String(20), unique=True, nullable=True)
mem2 = Column(String(20), unique=True, nullable=True)
class Deported(Model):
__tablename__ = 'deported'
id = Column(Integer, ForeignKey('
device.id'), primary_key=True)
fet1 = Column(String(20), unique=True, nullable=True)
fet2 = Column(String(20), unique=True, nullable=True)
pin = Column(String(20), unique=True, nullable=True)
configure_mappers()
>
> Any help would be very much appreciated, as I have been trying for a couple
> of days with no luck!
> Thank you
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
>
http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See
http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sqlalchemy+...@googlegroups.com.
> To post to this group, send email to
sqlal...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/sqlalchemy.
> For more options, visit
https://groups.google.com/d/optout.