ponyorm

Pony ORM Entity Unidirectional Mapping gives an error

守給你的承諾、 提交于 2019-12-24 05:49:43
问题 I have 2 tables. TableA & TableB TableA +------+----------------+-----------+ | id | some_attribute | tableB_id | +------+----------------+-----------+ id =primary key some_attribute =varchar TableB_id =foreign key TableB +------+----------------+ | id | some_attribute | +------+----------------+ id =primary key some_attribute =varchar My code: # establish a connection with the database (MySQL) db = Connection.Connection.connect_db_server_default() class TableB(db.Entity): _table_ = "table_b"

How to create instance of a table entry but not added in ponyorm?

筅森魡賤 提交于 2019-12-13 03:29:58
问题 How can I use a create an instance of a table definition without inserting a row to the corresponding Table. For example what I would like is: from pony import orm from pony.orm import Required db = orm.Database() class User(db.Entity): name = Required(str) address = Optional(str) db.bind(provider='sqlite', filename=':memory:') db.generate_mapping(create_tables=True) bob = User(name='bob') ### CODE FROM HERE ON IS WRONG BUT SHOWCASES WHAT I WANT # So far the database has not been modified bob

DatabaseSessionIsOver with Pony ORM due to lazy loading?

走远了吗. 提交于 2019-12-10 14:34:41
问题 I am using Pony ORM for a flask solution and I've come across the following. Consider the following: @db_session def get_orders_of_the_week(self, user, date): q = select(o for o in Order for s in o.supplier if o.user == user) q2 = q.filter(lambda o: o.date >= date and o.date <= date+timedelta(days=7)) res = q2[:] #for r in res: # print r.supplier.name return res When I need the result in Jinja2 -- which is looks like this {% for order in res %} Supplier: {{ order.supplier.name }} {% endfor %}

Pony ORM reports record “was updated outside of current transaction” while there is not other transaction

爱⌒轻易说出口 提交于 2019-12-07 17:31:40
问题 The code is quite simple, as follows: from pony.orm import Required, Set, Optional, PrimaryKey from pony.orm import Database, db_session import time db = Database('mysql', host="localhost", port=3306, user="root", passwd="123456", db="learn_pony") class TryUpdate(db.Entity): _table_ = "try_update_record" t = Required(int, default=0) db.generate_mapping(create_tables=True) @db_session def insert_record(): new_t = TryUpdate() @db_session def update(): t = TryUpdate.get(id=1) print t.t t.t = 0

PonyORM: What is the most efficient way to add new items to a pony database without knowing which items already exist?

家住魔仙堡 提交于 2019-12-07 03:55:48
问题 Forgive me if this is an obvious question but I'm new to pony and databases in general and didn't find the right part of the documentation that answers this question. I'm trying to create a database with companies and the locations where those companies have offices. This is a many-to-many relationship since each company is in multiple locations and each location can be host to multiple companies. I'm defining my entities as such: from pony import orm class Company(db.Entity): '''A company

PonyORM: What is the most efficient way to add new items to a pony database without knowing which items already exist?

Deadly 提交于 2019-12-05 07:57:53
Forgive me if this is an obvious question but I'm new to pony and databases in general and didn't find the right part of the documentation that answers this question. I'm trying to create a database with companies and the locations where those companies have offices. This is a many-to-many relationship since each company is in multiple locations and each location can be host to multiple companies. I'm defining my entities as such: from pony import orm class Company(db.Entity): '''A company entry in database''' name = orm.PrimaryKey(str) locations = orm.Set('Location') class Location(db.Entity)

PonyORM - multiple model files

筅森魡賤 提交于 2019-12-05 00:59:25
问题 I want to separate my model classes into separate files in a models directory. I would like to have a separate file for: general (authentication and global classes/tables) requisitions (tables used for requisitions) workorders (tables used for workorders) sales_orders (tables used for sales orders) ...etc I'm not sure how to structure my project to make that happen. I've tried putting my main imports into init .py in the directory and them importing those into the individual model files, but

PonyORM - multiple model files

那年仲夏 提交于 2019-12-03 16:45:22
I want to separate my model classes into separate files in a models directory. I would like to have a separate file for: general (authentication and global classes/tables) requisitions (tables used for requisitions) workorders (tables used for workorders) sales_orders (tables used for sales orders) ...etc I'm not sure how to structure my project to make that happen. I've tried putting my main imports into init .py in the directory and them importing those into the individual model files, but I don't know where to put my db.generate_mapping() so that all classes are available. I'm guessing this

problems with psycopg2 on google apps engine

心不动则不痛 提交于 2019-12-02 19:14:52
问题 I get a problem when i tried to implement framework - Pony ORM in my google app engine application. The point is that the Pony uses psycopg2 (PostgreSQL adapter), and when im trying to make a request to database it raises an exeption - that it cannot find the psycopg2 modul. (in local python enviroment - evrthg works correct) Well, ive tried to manually add the psycopg package folder to the root of my project, but recieve the next error: File "C:\Users\AcerFull\PycharmProjects\cloudepicerp

problems with psycopg2 on google apps engine

本秂侑毒 提交于 2019-12-02 11:50:59
I get a problem when i tried to implement framework - Pony ORM in my google app engine application. The point is that the Pony uses psycopg2 (PostgreSQL adapter), and when im trying to make a request to database it raises an exeption - that it cannot find the psycopg2 modul. (in local python enviroment - evrthg works correct) Well, ive tried to manually add the psycopg package folder to the root of my project, but recieve the next error: File "C:\Users\AcerFull\PycharmProjects\cloudepicerp\psycopg2__init__.py", line 50, in from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID