A game engine provides me with a
def __init__(self, steamid):
self.__steamid = steamid
class MyPlayer(game_engine.Player, Base):
gold = Column(Integer)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
Base = declarative_base()
class Player(game_engine.Player, Base):
__tablename__ = 'player'
_steamid = game_engine.Player.steamid
sqlalchemy.exc.ArgumentError: Mapper Mapper|Player|player could not assemble any primary key columns for mapped table 'player'
This is simpler than you might expect. The solution below is roughly equivalent to the one from r-m-n, but more straightforward because it uses modern declarative mapping. There is no need for
@hybrid_property, you can just inherit
steamid from the parent class.
# my_plugin.py class MyPlayer(game_engine.Player, Base): def __init__(self, steamid, gold): super().__init__(steamid) self._id = self.steamid self.gold = gold _id = Column('steamid', Integer, primary_key=True) gold = Column(Integer)