could not assemble any primary key columns for mapped table
See original GitHub issuemy model:
class Test(db.Model):
__tablename__ = "Test"
STN = db.Column(db.String(3), nullable=False, info='')
BEG_DATE = db.Column(db.Date, nullable=False, info='')
END_DATE = db.Column(db.Date, nullable=False, info='')
PRICE = db.Column(db.String(3), nullable=False, info='')
REMARK = db.Column(db.String(255), nullable=True, info='')
when I run my flask app, its tips could not assemble any primary key columns for mapped table
,Mysql database can create a database without a primary key, Why do I have to set the primary key?I don’t want to set the primary key, how can I solve it?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Could not assemble any primary key columns for mapped table
This stops SQLAlchemy from "seeing" that the columns are present, and consequently causes your model not to contain any primary key column.
Read more >[sqlalchemy] could not assemble any primary key columns for ...
How do I create an ORM type with no primary key columns? For some reason I'm getting: sqlalchemy.exc.ArgumentError: Mapper
Read more >Mapper could not assemble any primary key columns for ...
Hey, I'm trying to use reflection with SQLAlchemy 0.8 but I always get this exception: sqlalchemy.exc.ArgumentError: Mapper Mapper|links|links could not ...
Read more >ORM Configuration - SQLAlchemy 1.4 Documentation
How do I map a table that has no primary key?¶ ... The SQLAlchemy ORM, in order to map to a particular table,...
Read more >sqlalchemy 无primary_key 时报错解决办法could not assemble ...
sqlalchemy 无primary_key 时报错解决办法could not assemble any primary key columns for mapped ... 在大部分表中都会有个自增的id可以作为pk,就不会 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hi there -
please see https://docs.sqlalchemy.org/en/13/faq/ormconfiguration.html#how-do-i-map-a-table-that-has-no-primary-key
if your table has no columns that qualify as a candidate key then it cannot be used by the ORM, you would need to use core only, however, there’s really no such thing in relational databases as a table that doesn’t have a candidate key of some kind, because otherwise it means you can have multiple rows that are complete duplicates of each other, how would that be useful ?
@zzzeek Thank you for your answer, Eventually I decided to add a primary key to the database table.