[sqlalchemy] Application locking and SQLAlchemy

2012-12-02 Thread YKdvd
I'm starting to use SQLAlchemy to access a small, in-house database. I need to add some rudimentary concurrency handling, and just wanted to see if my general impression as to the SQLAlchemy implications are correct. As a hypothetical example, assume something like a Users table, and some

Re: [sqlalchemy] Application locking and SQLAlchemy

2012-12-02 Thread YKdvd
D'oh! And I had just been reading the docs about a commit expiring loaded object instances, which is what the refresh() would have done. So the mere accessing of that User object instance (say, UserObj.name=newNameFromEdit, or temp=UserObj.name) would first trigger a reload of that User from

[sqlalchemy] Multiple table join selectable update vs insert

2013-01-02 Thread YKdvd
I'm starting to work with an existing MySQL setup, where there's a master database (or, effectively, schema, it is all within one MySQL instance) with tables of general usefulness, and separate schemas for each specific project. So there is a table master.users with all the basic information

[sqlalchemy] Events (load and after_attach) for instance stamping

2013-01-10 Thread YKdvd
In the MySQL system I'm redoing with SQLAlchemy, there is effectively a master' schema that exists once top-level stuff (including a table describing projects) , and project schemas (one identical set of tables per project), which have project-level stuff. When an object is retrieved from a

Re: [sqlalchemy] Events (load and after_attach) for instance stamping

2013-01-10 Thread YKdvd
On Friday, January 11, 2013 2:34:09 AM UTC-4, Michael Bayer wrote: you can associate the instance event with the mapper() callable or Mapper class, and it will take effect for all mapped classes. I think that would work for my case, although I'm a little fuzzy as to the exact syntax to

Re: [sqlalchemy] Events (load and after_attach) for instance stamping

2013-01-11 Thread YKdvd
That sounds even nicer, and since I'm just starting out with no legacy code I've been meaning to try dropping 0.8 in even before it is final. It sounds like I could just do something like event.listen(MyDeclarativeSubclass, load, myStamperFunc). I popped in 0.8b2 and tried something

Re: [sqlalchemy] Events (load and after_attach) for instance stamping

2013-01-11 Thread YKdvd
On Friday, January 11, 2013 11:25:06 AM UTC-4, Michael Bayer wrote: in theory. It's new stuff and was very tricky to get it to work, so feel free to send a brief test along. Here's a minimal example I quickly put together - it retrieves from the database, but the handler doesn't seem to

[sqlalchemy] MySQL drivers

2013-01-24 Thread YKdvd
My main use of SQLAlchemy is in the Python incorporated into Autodesk's Maya graphics program, using the standard MySQL-Python driver. Unfortunately for the most recent Maya 2013 version Autodesk has compiled their Python (2.6.4) with Visual Studio 2010 for Windows, instead of the VS2008 used

[sqlalchemy] Re: Detached instances and lazy-loaded attributes

2013-01-24 Thread YKdvd
the stuff didn't have a lazy/eager option. I'll have no problem in this case to rejigger to eager-load at query time, or even make the relationships eager. Thanks for the feedback. On Thursday, January 24, 2013 2:54:14 PM UTC-4, YKdvd wrote: If I have an instance MyInstance with an attribute

[sqlalchemy] composite ForeignKeyConstraint with a constant, non-column member?

2013-04-07 Thread YKdvd
I'm using SQLAlchemy on an existing database, with some one-many with the many row connecting to a many-many department/status system. The main fields are something like this: Parent.id Parent.mainStatus Child.id Child.parent_link Child.department_id Child.status_id Department.id

[sqlalchemy] non foreign-key relationship between schemas

2013-05-24 Thread YKdvd
I'm working with a MySQL setup that has, say, a Studio database (or schema), and multiple Production schemas (Production_1, Production_2, etc). The Studio database has a seasons table, and the Production databases have episodes tables. Currently, the episodes table doesn't have a foreign key

[sqlalchemy] Re: non foreign-key relationship between schemas

2013-05-24 Thread YKdvd
Yeah, I was afraid of that, but I thought there might be something going on with the relationship layer that might do the knitting. It would be a constant value (per schema/engine) I could have provided to the engine, metadata, mapper or whatever, but it isn't in the Episode row explicitly.

Re: [sqlalchemy] non foreign-key relationship between schemas

2013-05-24 Thread YKdvd
Yup, all episodes in a Production schema would belong to one specific production row. I guess I was thinking about the relationship more in terms of the automatic loading of the collection, and being able to add/delete from it and have it reflected on flush. It looks like @property

[sqlalchemy] MutableDict.as_mutable(PickleType) blobs and mysqldump

2014-10-15 Thread YKdvd
I've got a SQLAlchemy model something like this: class MyUserl(AlchemyBase): ... webPrefs = Column(MutableDict.as_mutable(PickleType) ) which runs against a MySQL 5.5.31 (Debian) database table: CREATE TABLE myUserTable ( ... `webPrefs` blob DEFAULT NULL, ENGINE=`InnoDB` DEFAULT CHARACTER SET

[sqlalchemy] Retrofitting class inheritance

2014-12-06 Thread YKdvd
I inherited a database which has two tables containing some similar information, with additional differences. In terms of SQLAlchemy Class Inheritance Hierarchies docs, there is an engineer table and a manager table, but no Employee class or table. Porting to Python and SQLA initially my

[sqlalchemy] Polymorphic adjacency lists and many-to-many

2015-02-07 Thread YKdvd
I have model FruitCategories which uses the bidirectional adjacency list pattern (Node) from the documentation. It is used to create a many-to-many connection to a model, say, Fruit, with an association table (fruits_cats), again vanilla like the docs. This all works great. I have other

[sqlalchemy] Re: Polymorphic adjacency lists and many-to-many

2015-02-15 Thread YKdvd
Thanks for the pointer to the Generic Associations page, somehow I managed to miss that. I had the same qualms about referential integrity as the generic foreign description, but was hoping I was missing something. Doing separate association tables isn't really a big problem, just a bit of

[sqlalchemy] inspecting attribute_mapped_collection info of RelationshipProperty?

2017-02-22 Thread YKdvd
Let's say I have a model class Child, with an Integer column "birthOrder" and text column "birthSign", and a class Parent which has "children = relationship('Child', collection_class=attribute_mapped_collection('birthOrder'))". This gives Parent a dictionary "children", keyed by the birth

[sqlalchemy] Re: Unnecessary SELECTS for association object instances via composite key?

2016-09-01 Thread YKdvd
I think I may have found the issue. If I modify your example so that "C.k1" is a declared_attr, the assertion on the second C instance loads the (100,1000) record from table "ab" again. I originally had my "k1" in a mixin, but it looks like the mixin isn't involved, and it is purely the

[sqlalchemy] Re: Unnecessary SELECTS for association object instances via composite key?

2016-08-28 Thread YKdvd
I'll see if I can add in the equivalent of any of the weirdness from the left/right classes or whatever from my setup to break this example and find out where I've messed up... :) There's a couple of oddities from one of them that might be possibilities, its been a couple of years or more since

[sqlalchemy] Unnecessary SELECTS for association object instances via composite key?

2016-08-28 Thread YKdvd
I've got a situation where SQLAlchemy (1.0.14, accessing MySQL via PyMySQL 0.7.6) seems to be issuing unnecessary SELECTs to an Association Object table for instances that are already in the identity map. Hopefully I've extracted the essentials of my setup in the pseudo-example below.

[sqlalchemy] change history and (auto)flushing

2017-05-25 Thread YKdvd
I'm using "marshmallow-sqlalchemy" (mmsqla), a small wrapper around the "marshmallow" marshalling/serializing library. I'm using my defined mmsqla schemas to serialize a parent record with multi-level nested relationships and sending that to a webpage, which changes one of the relationship

[sqlalchemy] Re: Pool connections high-water, session query counter?

2017-09-08 Thread YKdvd
In a separate thread, Mike had a demo which kept a query count in a Session instance by stamping a reference to the Session in its connections. It got removed

Re: [sqlalchemy] Re: Pool connections high-water, session query counter?

2017-09-05 Thread YKdvd
ou say should only be doing reads, suggests it is data and query time > related. > > I'd use fine-grained logging with thread/process ids to identify slow > requests and potentially which kinds of operations are hitting the > issue. > > > > On Fri, Sep 1, 2017 at

[sqlalchemy] Re: Pool connections high-water, session query counter?

2017-09-01 Thread YKdvd
Turned on the slow query log, doesn't seem to be that. The fact that it isn't consistently bad for similar hits, and also seems to need some load to be exposed makes me thing either some contention while inside the request in Python, including lazy loads. I have been able to get some timings

[sqlalchemy] Pool connections high-water, session query counter?

2017-09-01 Thread YKdvd
We have an internal Flask/SQLAlchemy webapp using MySQL and served up using Apache and mod_wsgi. We recently upgraded the server, going from an older Debian/Apache2.2/MySQL5.5/mod_wsgi 3.x, to a current Ubuntu/Apache 2.4/MySQL5.7/mod_wsgi4.5.x. Something seems to be causing some of our page

[sqlalchemy] Hybrid property with subquery

2018-09-24 Thread YKdvd
I have an ORM setup with a "departments_milestones" table ("dm", DepartmentMilestone objects), with "department_id" and "seqOrder" Fields. Each department has a few records in this table, ordered within the department by "seqOrder" (so seqOrder is not unique). Another object "ShotsStatus"

Re: [sqlalchemy] Hybrid property with subquery

2018-09-26 Thread YKdvd
On Tuesday, September 25, 2018 at 9:09:24 PM UTC-3, Mike Bayer wrote: > > On Mon, Sep 24, 2018 at 12:22 PM YKdvd > > wrote: > > > > I have an ORM setup with a "departments_milestones" table ("dm", > DepartmentMilestone objects), with "depart

[sqlalchemy] Polymorphic relationships to different classes

2019-08-29 Thread YKdvd
Suppose I have two distinct and unrelated ORM classes, call them Powers, and Dominions (which are in tables "powers" and "dominions", both having an "id" field), and I want them both to have relationships to their own subclass of a single-table polymorphic setup, call it Things. class

[sqlalchemy] Marshmallow speed and lazy/eager loading

2019-09-21 Thread YKdvd
I'm using the "marshmallow" serialization library to dump out SQLAlchemy objects, and I'm trying to track down some slowness issues. The objects have various relationships (using marshmallow's Nested fields in the mm schema), and some of those have their own relationships, etc. As an example

[sqlalchemy] Re: Hybrid property "can't set attribute"

2019-12-19 Thread YKdvd
Ah, thanks very much, that's fixed it. I must have missed that in the docs - I think this started out as a Python property and they later added the hybrid decorator. On Thursday, December 19, 2019 at 4:34:34 PM UTC-4, YKdvd wrote: > > We have a "Users" model with this, wh

[sqlalchemy] Hybrid property "can't set attribute"

2019-12-19 Thread YKdvd
We have a "Users" model with this, which was a hybrid property to wrap the "email" column temporarily. The database column (MySQL 5.7) is "email", but defined by ORM as "_email", with an "email" hybrid property to access and set: _email = Column(u'email', String(255)) ... @hybrid_property

Index DDL not emitted

2014-06-02 Thread YKdvd
class Dummy(AlchemyBase): __tablename__ = dummy id = Column(Integer, primary_key=True) f1 = Column(Integer, index=True) When I create using the above on MySQL, the DDL is: CREATE TABLE dummy ( id INTEGER NOT NULL AUTO_INCREMENT, f1 INTEGER, PRIMARY KEY (id) ) Shouldn't there be an INDEX