[sqlalchemy] How can I duplicate mixin columns?

2016-09-16 Thread Jinghui Niu
For example, I have a Mixin as follow: class MyNoteMixin: note = Column(String) Now I have a subclass that inherit from the above Mixin, but needs two different columns both are of a note nature. Can I do something like: class Child(Base, MyNoteMixin as "Description", MyNoteMixin as

Re: [sqlalchemy] Multi-table deletes with PostgreSQL

2016-09-16 Thread Mike Bayer
On 09/16/2016 12:57 PM, Alex Grönholm wrote: I'm attempting to do a multi-table delete against PostgreSQL (psycopg2) with the following query: session.query(ProductionItem).\ filter(Project.id == ProductionItem.project_id, Project.code.in_(projects),

[sqlalchemy] Re: Multi-table deletes with PostgreSQL

2016-09-16 Thread Jonathan Vanasco
There is a super-old ticket about this - https://bitbucket.org/zzzeek/sqlalchemy/issues/959 (yes, I remembered that!) And there is a workaround here: https://groups.google.com/forum/#!topic/sqlalchemy/cIvgH2y01_o using the compilies system as suggested here

[sqlalchemy] Multi-table deletes with PostgreSQL

2016-09-16 Thread Alex Grönholm
I'm attempting to do a multi-table delete against PostgreSQL (psycopg2) with the following query: session.query(ProductionItem).\ filter(Project.id == ProductionItem.project_id, Project.code.in_(projects), ProductionItem.external_id.is_(None)).\

Re: [sqlalchemy] Re: Strange issue with SQLAlchemy History and generating unnecessary updates

2016-09-16 Thread 'Nicholas A Fries' via sqlalchemy
Hi Mike, Thanks for the detailed explanation and example code. I suspect this is exactly what is happening (that the deserialization library is using add instead of merge) - I will look over the code and confirm. Thanks! On Fri, Sep 16, 2016 at 7:05 AM, Mike Bayer

Re: [sqlalchemy] Re: Strange issue with SQLAlchemy History and generating unnecessary updates

2016-09-16 Thread Mike Bayer
On 09/15/2016 11:22 PM, 'Nicholas A Fries' via sqlalchemy wrote: Hi Mike. Thanks for the reply and clarification on how the history system is implemented. I will investigate further and review the code you mentioned. Right now, I can see that get_history() is showing changes for one of the

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Simon King
On Fri, Sep 16, 2016 at 10:49 AM, Jinghui Niu wrote: >> If you still want to store it as a string, I guess you'll need to try >> parsing it as a datetime and then fall back to parsing it as a date. > > > Exactly! That's my intention. I'm so excited that my idea has affirmed

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Jinghui Niu
> > If you still want to store it as a string, I guess you'll need to try > parsing it as a datetime and then fall back to parsing it as a date. Exactly! That's my intention. I'm so excited that my idea has affirmed by a pro now:) You haven't said what database you are using SQLite in Python

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Simon King
Another option would be to have separate columns for date and time, and leave the time column NULL when it's not present. If you still want to store it as a string, I guess you'll need to try parsing it as a datetime and then fall back to parsing it as a date. You haven't said what database you

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Jinghui Niu
If I store the as DateTime values and with a second column to indicate whether it's a date or datetime, it would look like this for a Date: col1: "2016-09-16 00:00:00", col2: "date only" It looks so messy to me:) I'd prefer to have Date and DateTime distinctively written in my database. I admit

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Jinghui Niu
Thanks for reply. The reason is simple. I plan in the future to accommodate datetime range into that column as well, so storing this logic as plain strings gives the most flexibility. This is a project that I'm learning by making. So I would like to try all the new features for later tasks. I'm

Re: [sqlalchemy] SQL expression for function (and/or method) dispatching?

2016-09-16 Thread Simon King
Ignore SQLAlchemy for the moment and describe what you are trying to achieve. It looks like you want to store dates and times as strings in your database (rather than the appropriate type), and yet still be able to perform date-related operations on them qhen querying. Is that right? Is there a