[sqlalchemy] after_update event is fired when I save a many-to-many relationship

2022-12-23 Thread waters greg
I'm trying to update an audit log table called 'loggings', here is the definition of the corresponding model: class *Logging*(Base): __tablename__ = 'loggings' id = Column(GUID(), primary_key=True, nullable=False, default=uuid4) target_id = Column(GUID(), doc="The ID of the altered ob

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Oh right, I've used the @property decorator before, just been a while. Thanks for the explanation of @hybrid_property. Makes sense. On Wed, Jun 7, 2017 at 5:32 PM, mike bayer wrote: > > > On 06/07/2017 06:19 PM, Greg Silverman wrote: > >> Thanks, it worked! >>

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Thanks, it worked! I tried something similar using the @hybrid_property decorator, but could not get it to work. What exactly is the difference between that and the @property decorator? Greg-- On Wed, Jun 7, 2017 at 5:08 PM, mike bayer wrote: > > > On 06/07/2017 02:31 PM, GMS wrote:

Re: [sqlalchemy] Re: How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Hi, Thanks for pointing that out. It's still throwing the same error, even when changed. Does not seem to like passing the column name to the column_property method. Greg-- On Wed, Jun 7, 2017 at 3:30 PM, Jonathan Vanasco wrote: > These are two different lines of code. The second o

Re: [sqlalchemy] Grouped data in a Flask/SQLAlchemy class

2017-04-24 Thread Greg Silverman
Yes, I can certainly do that. Sounds pretty simple, actually. I may have more questions as I dive into this. Thanks! On Mon, Apr 24, 2017 at 3:06 PM, mike bayer wrote: > > > On 04/24/2017 03:42 PM, Greg Silverman wrote: > >> My naive first response would be that I want

Re: [sqlalchemy] Grouped data in a Flask/SQLAlchemy class

2017-04-24 Thread Greg Silverman
on, Apr 24, 2017 at 12:21 PM, mike bayer wrote: > > > On 04/24/2017 12:51 PM, Greg Silverman wrote: > >> Hi Mike, >> I'm finally getting to this. Instead of having both a detail and grouped >> methods, I would like to have only the grouped method. I'm not su

Re: [sqlalchemy] Grouped data in a Flask/SQLAlchemy class

2017-04-24 Thread Greg Silverman
you please elaborate a bit how these would work within context of the class? Thanks! Greg-- On Wed, Mar 1, 2017 at 8:53 PM, mike bayer wrote: > > > On 03/01/2017 08:27 PM, GMS wrote: > >> I have the following class models: >> >> >> | class DiagnosisDetail(Model)

Re: [sqlalchemy] Grouped data in a Flask/SQLAlchemy class

2017-03-02 Thread Greg Silverman
/01/2017 10:22 PM, Greg Silverman wrote: > >> >> >> On Wed, Mar 1, 2017 at 8:53 PM, mike bayer > <mailto:mike...@zzzcomputing.com>> wrote: >> >> >> >> On 03/01/2017 08:27 PM, GMS wrote: >> >>

Re: [sqlalchemy] Grouped data in a Flask/SQLAlchemy class

2017-03-01 Thread Greg Silverman
ps(sorted_list_of_diagnosis_detail): > > for (dx_code, patient_id), details in > itertools.groupby(sorted_list_of_diagnosisdetail, keyfunc): > diagnosis_group = DiagnosisGroup( >dx_code, patient_id > ) > diagnosis_grou

Re: [sqlalchemy] Python datatime object issue with SQLite/SQLAlchemy

2016-11-11 Thread Greg M. Silverman
I should add: The specific queries I was running that were throwing the error all worked using your test case setup. Greg-- On Fri, Nov 11, 2016 at 10:50 AM, Greg M. Silverman wrote: > Hi Mike, > Modifications of your test made to point to the actual database file I am > using wo

Re: [sqlalchemy] Python datatime object issue with SQLite/SQLAlchemy

2016-11-11 Thread Greg M. Silverman
more. Interesting. Thanks! Greg-- On Thu, Nov 10, 2016 at 8:33 PM, mike bayer wrote: > > > On 11/10/2016 08:10 PM, horcle_buzz wrote: > >> I am using SQLAlchemy and am having an issue wrt to an SQLite error: >> >> >> | >> SQLiteDatetype only accepts Pythond

Re: [sqlalchemy] dealing with NULLS in 1-many relationships

2016-06-06 Thread Greg Silverman
Unfortunately, the data are out of our control. However, this solution looks like it will do the job. Thanks! Greg-- On Mon, Jun 6, 2016 at 5:54 PM, Mike Bayer wrote: > > > On 06/06/2016 11:21 AM, Horcle wrote: > >> I have the following models: >> >> class LabR

Re: [sqlalchemy] Re: Dynamically constructing joins

2015-03-25 Thread Greg Silverman
in_criteria[1:]: query = query.join(eval(table), eval(criterion)) Where the variables table and criterion were built lists, so that I ended up doing a Cartesian product of all my tables, which was giving me many problems, with aliasing being the least of it! Thanks! Greg-- On Tue, Mar 24, 2015 at 11:22

Re: [sqlalchemy] Issue with return results

2014-09-08 Thread Greg Silverman
Hi Jonathan, For the record, in my current setup, I installed python via Homebrew. Prior to that, I was using the Apple build of python, which would have been the 32-bit version that came with Lion. Greg-- On Mon, Sep 8, 2014 at 6:31 PM, Jonathan Vanasco wrote: > Looking at that issue,

Re: [sqlalchemy] Issue with return results

2014-09-04 Thread Greg Silverman
I think I am going to dump SQL Server and just go with Postgres. Much easier, and less of a headache. Fortunately, we are not yet in production. Thanks! Greg-- On Thu, Sep 4, 2014 at 8:31 PM, Horcle wrote: > Thanks. I forgot to mention that I had tried adding the encoding scheme

Re: [sqlalchemy] cannot access tables

2014-08-18 Thread Greg Silverman
SELECT default_schema_name FROM sys.database_principals WHERE name = ? AND type = 'S' On Mon, Aug 18, 2014 at 9:47 AM, Horcle wrote: > On Friday, August 15, 2014 8:28:41 PM UTC-5, Michael Bayer wrote: >> >> >> On Aug 15, 2

[sqlalchemy] cannot access tables

2014-08-15 Thread Greg Silverman
print 'A' Again, I am connecting fine with the database create.engine method (that is '42' is printing as expected), but when I run the inspector.get_table_names method with the given conditional it is printing the 'A' (I have tried other table names in the sam

[sqlalchemy] sqlite string concats and datetime arithmetics

2013-08-29 Thread Greg Yang
I'm trying to get a series of datetimes using func.datetime. The format of input is func.datetime(basetime, '+ NNN seconds'), which works nicely if the shift applied is constant. However I need to add 10, 20, 30 seconds, etc to this base time. So I want something like func.datetime(basetime, co

[sqlalchemy] unregister mapper event

2013-07-16 Thread Greg Yang
Is it possible to remove mapper events? Specifically I want to call event.remove(mapper, 'mapper_configured', fn) but I get an error back saying Mapper is not iterable. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this gro

[sqlalchemy] kivy and sqlalchemy

2013-07-10 Thread Greg Yang
I'm writing an application that uses kivy for GUI and sqlalchemy for ORM. Each has its own instrumentation system, and I initially planned to connect them by 1) mirroring relevant SA attributes in kivy at init, 2) work with only the kivy versions of the attributes for the duration of the app, 3)

Re: [sqlalchemy] Strange behavior with a class inheriting from AssociationProxy

2013-07-09 Thread Greg Yang
= relationship("A") > b = relationship("B") > > class B(Base): > __tablename__ = 'table_b' > id = Column(Integer, primary_key=True) > ab = relationship('AB', > collection_class=attribute_mapped_collection(

[sqlalchemy] Strange behavior with a class inheriting from AssociationProxy

2013-07-08 Thread Greg Yang
I created a class CorrelatedProxy inheriting from AssociationProxy that allows the creator function to depend on the owner instance of the association proxy. Essentially it gets a attribute 'correlator' of the something like lambda x: lambda y, z: Constructor(x, y, z), and then intercepts the _

Re: [sqlalchemy] self-referential one to many relationship with a kind of "composite foreign key"

2013-06-12 Thread Greg Yang
> > s = Session(e) > > a1 = A() > a2 = A(parent=a1) > a3 = A(parent=a1) > a4 = A() > > b1 = B(id=1, a_re=a1) > b2 = B(id=1, a_re=a2) > b3 = B(id=1, a_re=a3) > b4 = B(id=1, a_re=a4) > > b5 = B(id=2, a_re=a1) > b6 = B(id=2, a_re=a2) > b7 = B(id=2, a_re=

Re: [sqlalchemy] self-referential one to many relationship with a kind of "composite foreign key"

2013-06-11 Thread Greg Yang
ary" an aliased SELECT statement, or in 0.9 > maybe it can be a a JOIN, that represents all the intermediary rows. Might > work, might not, would have to spend a few hours with it. > > Is there a reason you can't just route to the related B.a.children.bsusing > proxies?

[sqlalchemy] self-referential one to many relationship with a kind of "composite foreign key"

2013-06-11 Thread Greg Yang
Consider these 2 mapped classes from sqlalchemy.engine import create_engine from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.orm import relationship from sqlalchemy.orm.session import sessionmaker from sqlalch

[sqlalchemy] Ordering by composite column gives sqlite3 OperationalError

2013-06-09 Thread Greg Yang
Right now query.order_by(composite) gives a sqlite3 operational error, because the rendered SQL is ORDER BY (composite_val1, composite_val2, composite_val3) instead of ORDER BY composite_val1, composite_val2, composite_val3. (The parenthesis is causing an error) For example, consider the code b

Re: [sqlalchemy] AssociationProxy's behavior with "== None" seems unintuitive

2013-06-08 Thread Greg Yang
Awesome! The changes should be able to cover the issue. On Saturday, June 8, 2013 12:40:51 PM UTC-5, Michael Bayer wrote: > > > On Jun 8, 2013, at 1:33 AM, Greg Yang > > wrote: > > > if __name__ == '__main__': > > engine = create_engine('sqlite:

[sqlalchemy] AssociationProxy's behavior with "== None" seems unintuitive

2013-06-07 Thread Greg Yang
Right now a filter clause AssociationProxy == None Consider the following code: from sqlalchemy.engine import create_engine from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.orm import relationship from sqlal

[sqlalchemy] How to disable Foreign Keys to clear database

2012-08-16 Thread Greg
Hi, I was naively trying to clear a db earlier in the day and I ran into this problem: 'Cannot delete or update a parent row: a foreign key constraint fails' So as anyone would do I've been searching online and through the documentation on how to turn the foreign keys off, on delete = Cascade,

[sqlalchemy] Re: Storing Nested Lists

2010-04-26 Thread greg
Excellent. Thanks very much. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more option

[sqlalchemy] Storing Nested Lists

2010-04-25 Thread greg
Hi All, I'm new to sqlalchemy. I've been reading the documentation and group archives, but can't really find an answer to my question. I suspect it's a question of terminology, and that I don't really know the term for what I'm looking for. Can I map a nested list to one column, and have my nest

[sqlalchemy] Re: Reflection, Foreign Keys, Auto Defaults, Oh My!

2009-04-24 Thread greg
I just noticed that part of this has been answered yesterday. I apologize for the redundancy; I did not think I had posted the earlier request. --greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlal

[sqlalchemy] Reflection, Foreign Keys, Auto Defaults, Oh My!

2009-04-24 Thread greg
our help. I'm looking forward to learning more about all of this! --greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@goo

[sqlalchemy] Linking Tables using Reflection

2009-04-24 Thread greg
, metadate, engine, autoload_with=engine) B = Table('Table_B', metadate, engine, autoload_with=engine) Now, how do I go about creating a link, say A_id, from table 'B' to table 'A.id' Thanks for your help! --greg --~--~-~--~~~---~--~~ Y

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-23 Thread Greg
The commit mentioned earlier fixed the issue. Thanks for all the help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscrib

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-23 Thread Greg
Thanks, I'll try this out and let you know how it goes. On Jan 23, 12:43 pm, Rick Morrison wrote: > Uh, did you guys not see my last message in this thread? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchem

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-23 Thread Greg
Yeah, I can get it to you, but in the reply box I'm not seeing anything here about attachments. There's just Send, Discard, Add Cc, or Edit Subject. I am set up to use this group only through the browser. On Jan 23, 12:35 pm, Don Dwiggins wrote: > Greg wrote: > > I think I f

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-22 Thread Greg
I think I found one that might help. Where can I upload this HTML file it generated? On Jan 22, 12:57 pm, Don Dwiggins wrote: > Greg wrote: > > Unfortunately, I'm connecting remotely via iODBC and do not have said > > tools. I'm running Ubuntu Linux, if you know of an

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-21 Thread Greg
Unfortunately, I'm connecting remotely via iODBC and do not have said tools. I'm running Ubuntu Linux, if you know of any way to get the same thing prettied up, let me know and I will. On Jan 21, 12:22 pm, Don Dwiggins wrote: > Greg wrote: > > As a disclaimer, this is a legac

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-21 Thread Greg
As a disclaimer, this is a legacy system in which I have no control over, so what you are about to see is pretty disturbing :) http://pastebin.com/m10d49ac1 The formatting is pretty crazy, I'm hoping you can make use of this. --~--~-~--~~~---~--~~ You received thi

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-21 Thread Greg
#x27;tb_FSAR_Data_SampArtReq', meta, autoload=True, autoload_with=engine) On Jan 21, 1:14 am, Michael Bayer wrote: > yeah i meant send along the CREATE TABLE to the mailing list here.     > or a describe, whatever shows us what column type might be failing. > > On Jan 20, 2

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-20 Thread Greg
How do I go about doing this? Showing the create table? On Jan 20, 4:54 pm, Rick Morrison wrote: > > I'm just trying to introspect an existing production database, not > > create any new tables. > > The structure of the table is read when reflecting the table: it's likely > that an unusual colum

[sqlalchemy] Re: MSSQL Reflection Error

2009-01-20 Thread Greg
n Jan 20, 2009, at 4:20 PM, Greg wrote: > > > > > I've got the following code to reflect an MS SQL 8 database using the > > latest stable pyodbc, python 2.5, and SQLAlchemy 5.1: > > > engine = create_engine('mssql://userXXX:pass...@mydsn', echo=False)

[sqlalchemy] MSSQL Reflection Error

2009-01-20 Thread Greg
I've got the following code to reflect an MS SQL 8 database using the latest stable pyodbc, python 2.5, and SQLAlchemy 5.1: engine = create_engine('mssql://userXXX:pass...@mydsn', echo=False) meta = MetaData() meta.bind = engine artreqs = Table('tb_FSAR_Data_SampArtReq', meta, autoload=True, aut

[sqlalchemy] problem with join, count on 0.5.0rc3

2008-11-08 Thread Greg
_zero().primary_key)) File "/opt/local/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc3- py2.5.egg/sqlalchemy/orm/query.py", line 241, in _only_mapper_zero raise sa_exc.InvalidRequestError("This operation requires a Query against a single mapper.") InvalidRequestError: This o

[sqlalchemy] Release posted on homepage!

2007-04-20 Thread Greg Copeland
I noticed current release information is now available on the SQLAlchemy homepage! Good job! Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, sen

[sqlalchemy] Re: Database Disconnection Detection

2007-04-03 Thread Greg Copeland
m now using, "except (sa.exceptions.DBAPIError, cx_Oracle.DatabaseError), e:". While I don't like having the cx_Oracle exception in there, at least I have explicit handling with the unknown/unexpected case broken out now. Greg P.S. Keep up the good work guys! On Apr 2, 5:06 pm, Mich

[sqlalchemy] Re: PyInstaller Support

2007-04-02 Thread Greg Copeland
ask your question. Hopefully the author will be able to better address your questions/concerns. Greg On Apr 2, 6:02 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > thats great. we are going to be checking in some code soon that will > look for alternate database modules via pkg_reso

[sqlalchemy] PyInstaller Support

2007-04-02 Thread Greg Copeland
perly imported. If you don't want to wait for the next release, search the google group and you'll find the proper hook file contents. Hope this isn't too much of a commercial. Greg --~--~-~--~~~---~--~~ You received this message because you are subs

[sqlalchemy] Re: Database Disconnection Detection

2007-04-02 Thread Greg Copeland
database and retry, I can try that later this week. My DB server is a shared server so shutting it down for the whole group is not well receieved. ;) > Paul Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Re: Database Disconnection Detection

2007-04-02 Thread Greg Copeland
On Apr 2, 12:36 pm, Paul Johnston <[EMAIL PROTECTED]> wrote: > Greg, > > If you can send the traceback you get when such an error occurs, that > would be helpful for providing Oracle support for this condition. > > Paul > I assume this means that the exception is n

[sqlalchemy] Re: Database Disconnection Detection

2007-04-02 Thread Greg Copeland
ns exist within the cool; having been previously reaped. Application attempts to query database. What does SA return? In this case, it should know it does not have any connections within its pool. Is this documented? Is there any documention which describes the known failure modes which SA detects?

[sqlalchemy] Re: Database Disconnection Detection

2007-04-02 Thread Greg Copeland
Frankly I'm very surprised this class of error has not been previously addressed. I'll have to test and see what happens. I was planning on doing the defensive coding, followed by the testing to make sure it is caught and recovers correctly. Greg On Apr 2, 12:36 pm, Paul Johnst

[sqlalchemy] Re: Update Latest News on website?

2007-04-02 Thread Greg Copeland
lem has already been addressed. Just some food for thought. Greg On Apr 2, 12:33 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > releases are announced on this mailing list as well as the Python > cheeseshop (and all feeds which aggregate it, such as planet > python). you can al

[sqlalchemy] Re: Database Disconnection Detection

2007-04-02 Thread Greg Copeland
QLAlchemy right now, assuming the DBAPI actually returns an exception? Greg > > On Apr 2, 2007, at 1:07 PM, Greg Copeland wrote: > > > > > I'm using sqlalcehmy 2.5 with cx_Oracle 4.2.1. What is the proper way > > to detect an sqlalchemy operation has lost its dat

[sqlalchemy] Update Latest News on website?

2007-04-02 Thread Greg Copeland
Perhaps I missed it, but it would be great if you guys would update the Latest News section on the SA homepage when a new release is made available. Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlal

[sqlalchemy] Database Disconnection Detection

2007-04-02 Thread Greg Copeland
n? If not, what exception will user code see? I found that various threads on automatic reconnection and I assume SA does not currently, reliably, support automatic database reconnection? Greg --~--~-~--~~~---~--~~ You received this message because you are subscri

[sqlalchemy] Re: memory leak with psyco

2007-03-21 Thread Greg Copeland
could test this by driving your application with a set of fixed inputs. One of the gotchas of using psyco is memory use goes through the roof in exchange for much improved performance. Greg On Mar 21, 10:49 am, "Andrew Stromnov" <[EMAIL PROTECTED]> wrote: > Usi

[sqlalchemy] Re: Functions with out parameters?

2007-03-09 Thread Greg Copeland
Great that's working. And Yuck! Having to do that directly on the cursor really makes me enjoy SA's capabilities. Can't wait until that's a supported feature. Keep up the good work guys! Greg On Mar 9, 10:42 am, "Michael Bayer" <[EMAIL PROTECTED]> wrote:

[sqlalchemy] Re: Functions with out parameters?

2007-03-09 Thread Greg Copeland
for now theres not really a good way to make it happen within SA's > querying facilities; youd have to drop into cx_oracle to do it. Dang it. I was afraid of that. How do I grab the cx_Oracle cursor from SA? Thanks, Greg --~--~-~--~~~---~--~~ You re

[sqlalchemy] Functions with out parameters?

2007-03-08 Thread Greg Copeland
racle function via the func method, which also has output parameters? Are they even supported? Function blah looks something like: create or replace function blah( arg1 IN VARCHAR2(15), arg2 IN INTEGER, arg3 IN INTEGER, arg4 OUT NOCOPY VARCHAR2 ) RETURN INTEGER ...