Comments (3)
Are you sure you've posted a correct example? The following works for me:
from pony.orm import *
db = Database()
class MyEntity(db.Entity):
a = Required(str)
b = Required(str)
PrimaryKey(a, b)
db.bind(provider='sqlite', filename=':memory:')
db.generate_mapping(create_tables=True)
ent = MyEntity(a='Key1', b='Key2')
commit()
primary_key = ent.get_pk()
>>> MyEntity[primary_key]
MyEntity['Key1','Key2']
from pony-doc.
My fault, sorry.
The tuple returned from get_pk() was getting converted to str to be stored in another table, a simple 'eval' solved it.
from pony.orm import *
db = Database()
class MyEntity(db.Entity):
a = Required(str)
b = Required(str)
PrimaryKey(a, b)
db.bind(provider='sqlite', filename=':memory:')
db.generate_mapping(create_tables=True)
with db_session():
ent = MyEntity(a='Key1', b='Key2')
primary_key = str(ent.get_pk())
ent = MyEntity[eval(primary_key)]
>>> MyEntity[eval(primary_key)]
MyEntity['Key1', 'Key2']
from pony-doc.
First of all I think this issue relates to pony itself, not pony-doc repository.
About composite keys - it was bug in Pony that we've fixed here. And will be released soon in Pony 0.7.7
from pony-doc.
Related Issues (2)
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 pony-doc.