Re: [sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-27 Thread Nathan Johnson
Hi Mike Thanks very much for all the feedback, 'expunging the expunges' and setting expire_on_commit=False worked a treat. Had to add commits for read operations too, which felt a little awkward, but works nicely. Nathan On Monday, 16 May 2022 at 19:19:56 UTC+1 Mike Bayer wrote: >

Re: [sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-16 Thread Nathan Johnson
tachedInstanceError: Parent instance is not bound to a Session; lazy load operation of attribute '_lookup' cannot proceed (Background on this error at: http://sqlalche.me/e/14/bhk3) ``` Thanks Nathan On Wednesday, 11 May 2022 at 15:25:11 UTC+1 Mike Bayer wrote: > the pattern you are using with expunge

[sqlalchemy] Re: add/update causing InvalidRequest for object with association_proxy lookup

2022-05-11 Thread Nathan Johnson
Oh, forgot to clarify, if it wasn't obvious... The LookUp is of course in the session already for the initial object creation, it's only on updating the created object that this error manifests. On Wednesday, 11 May 2022 at 11:24:41 UTC+1 Nathan Johnson wrote: > Hi > > I'm attempti

[sqlalchemy] add/update causing InvalidRequest for object with association_proxy lookup

2022-05-11 Thread Nathan Johnson
AWarning: Object of type not in session, add operation along 'Dave._lookup' won't proceed Would really appreciate some insight as to what I'm getting wrong here. Thanks Nathan -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example

Re: [sqlalchemy] Representing Tree Structures with sqlAlchemy

2017-07-23 Thread Nathan Mooth
Thanks for the example, it was exactly what I was looking for. On Friday, July 21, 2017 at 10:47:16 AM UTC-6, Mike Bayer wrote: > > On Fri, Jul 21, 2017 at 11:40 AM, Nathan Mooth <nat.d...@gmail.com > > wrote: > > So I have a tree-like data structure that I need to store

[sqlalchemy] Representing Tree Structures with sqlAlchemy

2017-07-21 Thread Nathan Mooth
So I have a tree-like data structure that I need to store in a way so that I can see all children or all parents of a query as well as their relative depth from the query item. In the past I have been using the closure table method demonstrated in this blog post

[sqlalchemy] Web API Wrapper for Informix Database

2016-04-03 Thread Nathan Nelson
ss.post(url, headers=req_headers, data=xml_request, verify=False) xml_root = _parse_unicode_xml(r.text) result = [{y.tag: y.text for y in x.iterchildren()} for x in xml_root. iter('row')] return result devices_query = 'SELECT * FROM device' devices = ccm_execute(devices_query

Re: [sqlalchemy] Join on subquery

2015-05-27 Thread Nathan
Thanks Michael, I really appreciate your help. On Wednesday, 27 May 2015 14:32:48 UTC+1, Michael Bayer wrote: On 5/27/15 2:43 AM, Nathan wrote: Hi, I'm trying to convert the following query to sqlalchemy: SELECT cg.id, cg.name cg.status, history.action, history.timestampFROM

[sqlalchemy] Join on subquery

2015-05-27 Thread Nathan
Hi, I'm trying to convert the following query to sqlalchemy: SELECT cg.id, cg.name cg.status, history.action, history.timestamp FROM customergame cg JOIN history ON history.id = (SELECT id FROM history h WHERE cg.id = h.customergame_id ORDER BY timestamp DESC LIMIT 1) ORDER BY gamename ASC

[sqlalchemy] how to model a collection of different types/classes using declarative

2014-11-17 Thread nathan
Sorry if I’m missing something basic and/or pretty obvious but I don’t know how to model collections of different types/classes. For example, let’s say I have these base types/classes: class Chicken(Base): __tablename__ = ‘chicken' id = Column(Integer, primary_key=True) name =

[sqlalchemy] simple join to parent with group_by

2014-11-04 Thread nathan
I’m trying to get a simple join working to a parent table with group_by. I’ve tried some variations working from the ORM tutorial but keep running into exceptions or I get multiple queries. I’m trying to get a single query that results in a collection of Client instances that’s joined to and

[sqlalchemy] foreign key relations

2014-08-03 Thread nathan
Hi, I have 3 tables and I'm concerned about possible issues with foreign key relations and how they might impact my code and its behavior. Maybe there's a circular reference issue or other concern I should know about with the tables below? A player and a song are both created separately and

Re: [sqlalchemy] foreign key relations

2014-08-03 Thread nathan
really appreciate your time. On Aug 3, 2014, at 5:14 PM, Rich Shepard rshep...@appl-ecosys.com wrote: On Sun, 3 Aug 2014, nathan wrote: A player and a song are both created separately and associated with a client. class Client(Base): __tablename__ = 'client' id = Column(Integer

[sqlalchemy] pycon 2014

2014-04-01 Thread nathan
Hi Mike, I really wish I could be there and see your presentations. They're usually recorded right? Just checking and hoping it's recorded... and if so, whoever records it does a great job. :) https://us.pycon.org/2014/speaker/profile/455/ Introduction to SQLAlchemy

[sqlalchemy] instance is not bound to a session

2014-02-05 Thread nathan
Hi, I'm looping writing Media objects with SA, which are just rows in the db that represent media files. The same Account object/instance is used during each iteration of the loop and contains the user's username, among other things. account =

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-10-03 Thread Nathan Mailg
, and it works! Sorry to have to ask this, but I'm stuck and need to get this working. Thanks again for all the help! On Oct 1, 2013, at 1:22 PM, Nathan Mailg nathanma...@gmail.com wrote: Thanks Mike, that works! I really appreciate you taking the time to show me how to get this working

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-10-03 Thread Nathan Mailg
. On Oct 3, 2013, at 2:35 PM, Nathan Mailg nathanma...@gmail.com wrote: Sorry for this follow-up, but I'm really at a loss as to what to check next… What should I do if after I insert a new Appl row, the query we've worked on in this thread is *not* finding it, i.e. it's not being returned

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-10-01 Thread Nathan Mailg
Thanks Mike, that works! I really appreciate you taking the time to show me how to get this working. Do you have an amazon wish list or something like that somewhere? On Sep 30, 2013, at 2:09 PM, Michael Bayer mike...@zzzcomputing.com wrote: qlast, qfirst = 'a', 'b' d =

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-24 Thread Nathan Mailg
On Sep 20, 2013, at 11:59 AM, Michael Bayer mike...@zzzcomputing.com wrote: Ok now I'm still not following - in this case, row is a NamedTuple, or a mapped instance? if its a NamedTuple then you don't have the service of traversing along object relationships available since the

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
).\ join(Appl.city).\ join(c, Appl.city).\ order_by(q1.c.lastname, q1.c.firstname) but that returns: […] File /Users/nathan/projects/env/lib/python2.7/site-packages/SQLAlchemy-0.8.2-py2.7-macosx-10.8-x86_64.egg/sqlalchemy/orm/mapper.py, line 1765, in common_parent

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
they're getting at when I look at http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-DISTINCT. On Sep 18, 2013, at 5:39 PM, Nathan Mailg nathanma...@gmail.com wrote: Thanks Mike for all the help! I think we're really close. Unfortunately, the DISTINCT ON (refid) * syntax

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-19 Thread Nathan Mailg
On Sep 19, 2013, at 3:07 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 19, 2013, at 2:46 PM, Nathan Mailg nathanma...@gmail.com wrote: c = aliased(City) q2 = s.query(q1).\ join(Appl.city).\ join(c, Appl.city).\ order_by(q1.c.lastname, q1.c.firstname) why

Re: [sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-18 Thread Nathan Mailg
= aliased(q1, 'd_q_a') q2 = s.query(q1).order_by(q1.c.lastname, q1.c.firstname) q2.all() On Sep 17, 2013, at 6:39 PM, Nathan Mailg nathanma...@gmail.com wrote: I'm using SA 0.8.2 and trying to port this query that works with PostgreSQL 9.2.4: WITH distinct_query AS ( SELECT

[sqlalchemy] using WITH query AS, cte() with postgresql

2013-09-17 Thread Nathan Mailg
I'm using SA 0.8.2 and trying to port this query that works with PostgreSQL 9.2.4: WITH distinct_query AS ( SELECT DISTINCT ON (refid) * FROM appl WHERE lastname ILIKE 'Williamson%' AND firstname ILIKE 'd%' GROUP BY refid, id, lastname, firstname, appldate

[sqlalchemy] Mutating behavior of InstrumentedAttributes

2011-10-11 Thread Nathan Rice
I need to add some processing to mapped attributes. For instance, some extra client side validation, returning attribute values embedded in markup, etc. Is there a better way to do this than to change the column definition (i.e. Column(name, type_, key=_name)) and adding a descriptor to the

[sqlalchemy] Incorrect SQL generated for INSERT into PostgreSQL

2011-09-26 Thread Nathan Robertson
Hi, I've come across a bug (hopefully in my configuration) where SQLAlchemy will generate an INSERT statement for a table with a SERIAL primary key which PostgreSQL errors on. I'm running EnterpriseDB's Postgres Plus 8.4 on openSUSE 11.4 x64, with Python 2.7, SQLAlchemy 0.7.2 and psycopg2 2.4.2.

Re: [sqlalchemy] Incorrect SQL generated for INSERT into PostgreSQL

2011-09-26 Thread Nathan Robertson
On Mon, Sep 26, 2011 at 11:05 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 26, 2011, at 2:50 AM, Nathan Robertson wrote:       Column('custid', Integer, Sequence('test.customer_custid_seq'), primary_key=True), for the Sequence, as with all schema items, you need to specify

Re: [sqlalchemy] Incorrect SQL generated for INSERT into PostgreSQL

2011-09-26 Thread Nathan Robertson
On Mon, Sep 26, 2011 at 11:05 PM, Michael Bayer wrote: On Sep 26, 2011, at 2:50 AM, Nathan Robertson wrote:       Column('custid', Integer, Sequence('test.customer_custid_seq'), primary_key=True), for the Sequence, as with all schema items, you need to specify the schema portion

Re: [sqlalchemy] Deferred properties are sometimes compiled unnecessarily?

2011-05-27 Thread Nathan Wright
On Thursday, 26 May 2011 06:42:55 UTC-7, Michael Bayer wrote: On May 25, 2011, at 10:52 PM, Nathan Wright wrote: Hi all, I've run into an issue when mapping a deferred column_property that uses a custom SQL construct. I get a KeyError: 'default' because there is no compile function

[sqlalchemy] Deferred properties are sometimes compiled unnecessarily?

2011-05-26 Thread Nathan Wright
the NoSuchColumnError message to not cast key (ie, the select) to a string. Perhaps the repr could be used instead? If I'm way off base feel free to let me know, heh, but hopefully this helps! :) Cheers, Nathan -- You received this message because you are subscribed to the Google Groups sqlalchemy

[sqlalchemy] Struqtural for SQL Alchemy

2010-07-17 Thread Nathan Rice
Wanted to drop by and mention that I just released the first public version of Struqtural. In a nutshell, Struqtural tries to make it as easy as possible to get data into a database, out of a database (as python objects) and to build some of the more common complex table arrangements. Struqtural

[sqlalchemy] Re: Locking tables

2009-11-02 Thread Nathan Harmston
/speeding-up-inserts-on-mysql/ Thanks for the advice, Nathan 2009/10/31 Michael Bayer mike...@zzzcomputing.com: On Oct 30, 2009, at 9:45 AM, Nathan Harmston wrote: Hi, I have a script which will process a large amount of data and save some of those results to the database. This takes

[sqlalchemy] Locking tables

2009-10-30 Thread Nathan Harmston
and insert operate? And can I find a way around this? Nathan --~--~-~--~~~---~--~~ 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 unsubscribe from

[sqlalchemy] Re: Vertical partitioning, mappers and foreign keys

2009-08-18 Thread Nathan Harmston
'] [] With nothing in the species..I can't understand whats going on ... my only thought is that cll2spe_table isn't being found correctly. Is there something going wrong. I am using 0.5.3 of SQLAlchemy. Any help greatly appreciated yet again, Nathan PS I continued the old thread as its still regarding

[sqlalchemy] Vertical partitioning, mappers and foreign keys

2009-08-14 Thread Nathan Harmston
via the t_engine. How can I make it explicitly know this here? I have tried using different metadata bindings but to no good. Any pointers/help would be greatly appreciated? Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed

[sqlalchemy] Accessing attributes hidden by a join

2009-08-04 Thread Nathan Harmston
) is this possible to do aswell? Many thanks in advance Nathan --~--~-~--~~~---~--~~ 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 unsubscribe from this group

[sqlalchemy] Unique parent class and various subclasses

2009-07-07 Thread Nathan Harmston
anybody done anything like this before? Is there a simple way of doing this, maybe at the level of the mapper? Many thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Accessing classes a table away in a mapper - why does this work?

2009-05-27 Thread Nathan Harmston
tried putting the alias call on the end of the secondary join, which makes it work perfectly. Without it calling sentence.genes gives me all of the genes found in all of the sentences. So my question is really ... why does this work? What effect does the alias have? Many thanks in advance, Nathan

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-20 Thread Nathan Harmston
The problem was solved by using a join query and then specifying both foreign keys and the secondary argument to the relation. Many thanks, Nathan secondary = sentences_table.join(tag_table.join(processed_tags_table, processed_tags_table.c.tag_id == tag_table.c.tag_id

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-20 Thread Nathan Harmston
to finish it off. Many thanks in advance Nathan 2009/5/20 Nathan Harmston iwanttobeabad...@googlemail.com: The problem was solved by using a join query and then specifying both foreign keys and the secondary argument to the relation. Many thanks, Nathan secondary

[sqlalchemy] Accessing classes a table away in a mapper

2009-05-18 Thread Nathan Harmston
) UnmappedColumnError: No column sentences.sentence_id is configured on mapper Mapper|Zone|zones Any pointers greatly appreciated! Many thanks Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group

[sqlalchemy] Joined table inheritance mapping issues

2009-05-18 Thread Nathan Harmston
later? Many thanks in advance, yet again, Nathan --~--~-~--~~~---~--~~ 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 unsubscribe from this group

[sqlalchemy] Using orderedlist with a secondary table

2009-01-30 Thread Nathan Harmston
) File /cluster/soft/Linux_2.6_64/lib/python2.5/site-packages/SQLAlchemy-0.4.8-py2.5.egg/sqlalchemy/orm/attributes.py, line 1218, in init oldinit(instance, *args, **kwargs) File /cluster/home/nathan/work/workspace/txtmining/Registry.py, line 258, in __init__ self.authors.append(a) File

[sqlalchemy] Re: SQL Expressions as Mapped Attributes

2009-01-27 Thread Nathan Harmston
of the Species object with a list of names in an attribute called names. How do I accomplish this? Also what do you mean by the correlated criterion of the column_property I have looked for this and have been unable to find it. Many thanks in advance, Nathan 2009/1/26 Michael Bayer mike...@zzzcomputing.com

[sqlalchemy] SQL Expressions as Mapped Attributes

2009-01-26 Thread Nathan Harmston
], species_table.c.rank=='species').alias('speciesfooalias')) I get the correct output. I am using SQLAlchemy 0.4.8 I am pretty confused by this. Any help is very much appreciated. Many thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message because you

[sqlalchemy] Looking for a pattern/simple way to simplify parsing and storing files in a database

2009-01-13 Thread Nathan Harmston
(Gb) and I dont want to saturate my database server with requests and likewise I only have limited memory on my machines. Have I missed something simple in the documentation? My code is below: Many thanks in advance, Nathan document_table = Table('documents', metadata

[sqlalchemy] exceptions.ArgumentError when trying to map class to a table

2008-12-17 Thread Nathan Harmston
this column (or use a viewonly=True relation). Any help greatly appreciated, Many thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email

[sqlalchemy] Problem Mapping table/relationship to a dictionary.

2007-08-24 Thread Nathan Harmston
has has node1 and 1 node 2. IS there a pattern in sqlalchemy for doing this sort of thing, I noticed in the new version of SQLalchemy you can map to sets, but I m a little clueless where to start. Any help muchly appreciated. Nathan --~--~-~--~~~---~--~~ You

[sqlalchemy] Problems trying to run a query - typeerror

2007-06-10 Thread nathan harmston
given) Does anyone know what the problem is? Is it the way I ve programmed this using metaclasses or is it sqlalchemy and the way in instantiates objects or even both? Many Thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message because you

[sqlalchemy] Mapping existing structure of a database

2007-06-04 Thread nathan harmston
? If not is there any advice you have to actually use SQLAlchemy in such a way. I m trying to create an API to my database and dont really want to have to declare all the tables again. Many Thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: Mapping existing structure of a database

2007-06-04 Thread nathan harmston
What kind of overhead is associated with using the autoload flag? What kind of overhead would be associated with this over a network? (with a remote database). Is there a way to dump the structure of a database to a file and import this as a kind of module? Thanks Nathan