-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to change the "id" column into "_id" #9
Comments
Yes, it is hard-coded somewhere. I will try to change it once I have more time. The core code for quick_orm has only 200+ lines, if you want, you can read Best Regards, Tyler Long On Thu, Feb 21, 2013 at 5:15 PM, pengqi [email protected] wrote:
Best Regards, Tyler Long Home page: http://www.tylerlong.me |
Compared to sqlalchemy, quick_orm provides simplicity, but loses It was designed according to my own programming experience, so I ignored On Fri, Feb 22, 2013 at 4:52 PM, Tyler Long [email protected] wrote:
Best Regards, Tyler Long Home page: http://www.tylerlong.me |
Thanks. I have added the feature: The "id" filed name can be user-defined now. See following example: # coding: utf-8
# test.py
# https://github.com/tylerlong/quick_orm
# pip install quick_orm
from quick_orm.core import MyDeclarativeMeta, Database, StringUtil, models
from sqlalchemy import Column, String, Text
__metaclass__ = Database.DefaultMeta
class Users :
__id__ = 'user_id'
last_name = Column(String(50))
first_name = Column(String(50))
@Database.foreign_key(Users, ref_name='author', backref_name='posts')
class Posts :
__id__ = 'post_id'
title = Column(String(200))
content = Column(Text)
Database.register()
if __name__ == '__main__':
db = Database('mysql://root:[email protected]:3306/webscraping?charset=utf8')
db.create_tables()
user = Users()
user.last_name = 'Qi'
user.first_name = 'Peng'
db.session.add_then_commit(user)
post = Posts()
post.author = user
post.title = 'Life is short.'
post.content = 'You need Python.'
db.session.add_then_commit(post) |
Thank you so much! I will integrate your code into the quick_orm after reviewing and testing. On Tue, Mar 5, 2013 at 2:09 PM, pengqi [email protected] wrote:
Best Regards, Tyler Long Home page: http://www.tylerlong.me |
Hello,
I tried to change the "id" column into "_id", but failed. The exception is as following:
sqlalchemy.exc.NoReferencedColumnError: Could not create ForeignKey 'users.id' on table 'posts': table 'users' has no column named 'id'
It seems there is other hard-coded in the library.
The code is as following:
Thanks,
Qi
The text was updated successfully, but these errors were encountered: