besides the idea of using getattr(), as these are object attributes it's
probably a good idea to name them differently from those columns. See the docs
at
https://docs.sqlalchemy.org/en/14/orm/mapping_columns.html#naming-columns-distinctly-from-attribute-names
for strategies on how to achieve
Yep. That seems fine. Thanks.
SQLAlchemy doesn't escape or quote the name. I checked using
inspection = inspect(Student)
return [c_attr.key for c_attr in inspection.mapper.column_attrs]
On Monday, April 12, 2021 at 5:55:07 AM UTC-5 Richard Damon wrote:
> On 4/12/21 12:29 AM, Rob Ro
Hi Simon
Again you really helped me out. I don't know what point I missed, but
now it works. As usual it's not as simpe le or lets say there are a lot
more code pieces to change before I can really test it in my code. But I
got it.
just one more thing:
I often have to check if a given tpye t
Here's a standalone working example:
import sqlalchemy as sa
import sqlalchemy.orm as saorm
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Objekt(Base):
__tablename__ = "objekt"
id = sa.Column(sa.Integer, primary_key=True)
typ_id = sa.Column
class Objekt(db.Model):
__tablename__ = 'objekt'
def __init__(self,**kwargs):
super().__init__(**kwargs)
id = db.Column(db.Integer, primary_key=True)
typ_id = db.Column(db.Integer, db.ForeignKey('objekt_typ.id'))
typ= db.relationship("ObjektTyp")
name =
I don't understand this comment:
> I though on polymorphic_on, but I think that does not work because of the
> fact that type_id ha a foreign key ...
As far as I can tell, you ought to have this in the base class:
__mapper_args__ = {
'polymorphic_on': typ_id
}
And this in the s
I run into a problem and don't know how to solve it.
The theory is very simple: I habe one base class table with name, id
and type column
The child class shall have a unique type_id (all child_class1 objekt
shall get type_id 7, all child_class2 objekts type_id = 8, ...)
How can I map the base
I run into a problem and don't know how to solve it.
The theory is very simple: I habe one base class table with name, id and
type column
The child class shall have a unique type_id (all child_class1 objekt
shall get type_id 7, all child_class2 objekts type_id = 8, ...)
How can I map the base
option #1 seems much simpler I'd likely start with that
re uuid, I usually take the "existing" ids and put them in a dictionary so I
know which ones to skip, absolutely. I don't understand what the "list
comprehension" approach would entail that isn't using a hash lookup of some
kind.
On S
On 4/12/21 12:29 AM, Rob Rosenfeld wrote:
> Hi All,
>
> I'm using SQLAlchemy to access a legacy MSSQL database. I'm using
> the autoload feature to load the schema from the database.
>
> In this example I'd like to read data out of the column named
> "1st_period" in the database. The following
10 matches
Mail list logo