Comments (1)
I'm not sure this is a spot on answer but I've gotten compound keys to work. If you have two tables, TABLE and FOREIGN, both of which are auto-mapped. One can subclass the latter table as follows :
class FOREIGN(AutomapModel):
__tablename__ = "ForeignTable"
__endpoint__ = "android"
fk_A = Column("A", Integer)
fk_B = Column("B", Integer)
__table_args__ = (ForeignKeyConstraint((fk_A, fk_B), ("TABLE.A","TABLE.B")), {})
# __table_args__ = (ForeignKeyConstraint((fk_A, fk_A), (TABLE.A, TABLE.B)), {}) # If TABLE is itself defined as an AutoModel subclass before this table and in the same file.
I got this working after reworking the Sandman 2 code base a little, I've submitted a PR accordingly but I'm awaiting acceptance/rejection thereof. If you want to pull my variant let me know and I'll post the URL. Then one might ask if you have to map the other fields in FOREIGN and the answer is not SQLAlchemy handles this for you. If you define your own TABLE use the second variant of __table__args__
Within my own notes I have the following links 1 is mostly thoeretical, 6 discusses foreign keys, 2, 3, 4 and 7 are more convenient for resolving the problem and 5 provides a nice script for identifying compound keys.
from sandman2.
Related Issues (20)
- indentation error in __main__.py", line 61
- Error creating backref HOT 1
- No module named 'sandman2.api'
- Errors generated by table names containing spaces; unable to start sandman2ctl HOT 1
- Seems like `exclude_tables` not working in call to get_app
- YOUR WEBSITE IS DOWN!
- AWS ECS
- How to use this with ForeignKey table
- howto apply sqlalchemy 1.4.15 HOT 1
- Where is the package?
- AWS ECS - Deploy as a lambda container image
- Is it possible to serialize the models/code that sandman2 generates?
- how to find a datetime value?
- ValueError: The name 'admin' is already registered for a different blueprint. Use 'name=' to provide a unique name.
- Sandman Error for composite primary keys
- Is it possible to get access to stored procedures and functions?
- 'LocalStack' object has no attribute '__ident_func__' error on launch HOT 2
- About MS SQL HOT 1
- Support linking via foreign indices
- Generate swagger document for exposed REST API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sandman2.