The game engine provides me with the Player class with the steamid property (coming from C ++, this is just a basic example of how it will look in Python):
# game_engine.py class Player: def __init__(self, steamid): self.__steamid = steamid @property def steamid(self): return self.__steamid
Then I will go to a subclass of this class by adding the gold attribute:
Now I need to save the gold player in the database with the steamid player as the primary key for identifying the player. How can I tell SQLAlchemy to use the steamid base class steamid as the primary key?
Here's something stupid I've tried:
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.hybrid import hybrid_property import game_engine Base = declarative_base() class Player(game_engine.Player, Base): __tablename__ = 'player' _steamid = game_engine.Player.steamid @hybrid_property def steamid(self): return type(self)._steamid.__get__(self)
But yes, it was a long shot ...
sqlalchemy.exc.ArgumentError: Mapper Mapper|Player|player could not assemble any primary key columns for mapped table 'player'
source share