[sqlalchemy] session clean-up problem?

2009-08-27 Thread Gloria W
Hi all, We're hitting a weird bug here. I'm doing a standard query with filters, and this is appended to the end: resultObj = resultObj.order_by(Member.lastname, Member.firstname, Member.middleinitial,

[sqlalchemy] AttributeError upon postgres_returning

2009-03-13 Thread Gloria W
Hi all, I am trying to use the postgres_returning feature with the latest svn checkout of SqlAlchemy, Python 2.5.2, and Postgresql 8.3. I have a declarative_base, which works in the declarative base context. I get it's table reference this way: al_table =

[sqlalchemy] Re: AttributeError upon postgres_returning

2009-03-13 Thread Gloria W
Argh! I knew it had to be something simple. Thanks! --~--~-~--~~~---~--~~ 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] How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Gloria W
Hi again, I have this table, which has a composite primary key, and no sequence: # \d log_members Table public.log_members Column | Type | Modifiers +-+--- memberID | integer | not null logentryID | integer | not null Indexes: log_members_pkey

[sqlalchemy] Re: How to best represent a Postgresql table with (1) a composite key, and (2) no sequence

2009-03-13 Thread Gloria W
Excellent, thank you. I won't get to try this until Monday. Gloria --~--~-~--~~~---~--~~ 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

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
I've traced it further, and it's an odd problem. This syntax works fine: memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)).order_by (MemberProfile.memberID) memberProfile = memberProfile.filter(MemberProfile.city == 'Jamaica')

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
I've traced it further, and it's an odd problem. This syntax works fine: memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)).order_by (MemberProfile.memberID) memberProfile = memberProfile.filter(MemberProfile.city == 'Jamaica')

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
Ahh, true. I switch the order of these operations, and always the second one fails, no matter what. How should I debug this problem? Thank you, Gloria --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
Just a quick update: A forced flush between queries does no good. Creating a new instance for each query seems to be the only immediate cure. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
Understood. In my constructor, I was using a shared global declarative_base, and a single session instance: metdata = Base.metadata engine = create_engine(config.db_conn) engine.echo = False Session = sessionmaker(bind=engine) self.session = Session() Only the self.session

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-09 Thread Gloria W
I will put one together with a small database comprised of three tables. Give me a couple of days, and I will have it to you. Thank you, Gloria --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Hi All, I have three classes, all using the same declarative_base() instance, as follows: In a config file: global Base Base = None def initBase(): global Base if not Base: Base = declarative_base() return Base

[sqlalchemy] Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Hi All, I have three classes, all using the same declarative_base() instance, as follows: In a config file: global Base Base = None def initBase(): global Base if not Base: Base = declarative_base() return Base

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
Wow, awesome, it works, thank you! ~G~ --~--~-~--~~~---~--~~ 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, send email to

[sqlalchemy] Re: Missing FROM clause on a one-to-many declarative_base mapping

2009-02-05 Thread Gloria W
OK, a new problem on the same model: I try this in my unit test: memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)).order_by (MemberProfile.memberID).filter(MemberProfile.city == 'Jamaica').all() and I get this error: Traceback (most recent call

[sqlalchemy] Re: Need SqlAlchemy Model Advice for a table with many foreign keys.

2009-02-04 Thread Gloria W
Thanks for this response. I do need all of the data available at once. Specifically, here is what I'm trying to do. I'm following this example right from the docs: from sqlalchemy import ForeignKey from sqlalchemy.orm import relation, backref class Address(Base): ... __tablename__ =

[sqlalchemy] Re: Need SqlAlchemy Model Advice for a table with many foreign keys.

2009-02-04 Thread Gloria W
Excellent, thank you! Getting closer. I now use the same declarative_base on all instances, and I can now successfully refer to the relation() classes as actual class names instead of strings. During this query: memberProfile = session.query(MemberProfile).filter_by (memberID=81017).first() I

[sqlalchemy] Re: Need SqlAlchemy Model Advice for a table with many foreign keys.

2009-02-04 Thread Gloria W
Just to make it easier to read, I'm missing a FROM clause: sqlalchemy.exc.ProgrammingError: (ProgrammingError) missing FROM- clause entry for table member_profiles at character 5151 I read from the archive that this was a bug in 0.4. Thanks again, Gloria

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-03 Thread Gloria W
D'OH! (slaps head) Thanks for pointing this out, it makes perfect sense. I got it working by getting it from the DB, and merging it into the current session, then deleting: def DELETE(self,dmemberid): x = MemberInfo() memberProfile = x.GET(memberid=dmemberid,raw=True) merged_obj =

[sqlalchemy] Need SqlAlchemy Model Advice for a table with many foreign keys.

2009-02-03 Thread Gloria W
Hi all, thanks for this really helpful list. My question now involves trying to figure out the correct way to map this legacy database to SqlAlchemy objects using the declarative_base model. This database has two main tables, members, and member_profiles, where a memberID is the foreign key

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-02 Thread Gloria W
Thanks for taking the time to respond. I still get an error, please see below. I show the record, just after a successful insert. I then show the error on delete. When I go into the db and manually delete these records, they exist as expected, and the deletion is successful. Thank you in

[sqlalchemy] Lazy load issue when using declarative_base methodology?

2009-01-28 Thread Gloria W
This is a strange problem. I'd appreciate any assistance. I have a class set up using the declarative_bass model, set up in this way: member_profile_table = MemberProfile.__table__ metdata = Base.metadata engine = create_engine(config.db_conn) Session = sessionmaker(bind=engine)

[sqlalchemy] Re: Lazy load issue when using declarative_base methodology?

2009-01-28 Thread Gloria W
on? does the testfile use same engine/.. setup as below? On Wednesday 28 January 2009 19:21:54 Gloria W wrote: This is a strange problem. I'd appreciate any assistance. I have a class set up using the declarative_bass model, set up in this way:   member_profile_table = MemberProfile.__table__

[sqlalchemy] Odd inheritance issue

2009-01-25 Thread Gloria W
Hi All, I have something stuping me right now. I'm using SqlAlchemy . 0.5.2 and Python 2.6. My issue is as follows: This class works perfectly: import sys import pprint import pdb from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import *

[sqlalchemy] Re: Odd inheritance issue

2009-01-25 Thread Gloria W
This should be called Odd Aggregation Issue. I am almost certain it's not related to inheritance, which is nested further up in the MemberProfile and Gender objects (which also work file). --~--~-~--~~~---~--~~ You received this message because you are subscribed

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-07-01 Thread Gloria W
Got it, thanks for your 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 unsubscribe from this group, send email to [EMAIL

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-30 Thread Gloria W
I thought this was a scope problem, but it seems to be even bigger. This is the error I get: OperationalError: (OperationalError) (1067, Invalid default value for 'date_created') u'\nCREATE TABLE fu_op_requests (\n \tfu_op_requests_id INTEGER NOT NULL AUTO_INCREMENT, \n\tname VARCHAR(50),

[sqlalchemy] Re: MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-29 Thread Gloria W
This gives me an error: sqlalchemy.Column('date_created', mysql.MSTimeStamp, sqlalchemy.PassiveDefault(text(CURRENT_TIMESTAMP)), nullable=False)) NameError: global name 'text' is not defined --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] MySQL 5.0 DateTime initialization during Table creation is failing.

2008-06-28 Thread Gloria W
Hi All, Looking back in these posts, I tried several older variants of MySQL datetime column initialization discussed here, and they're not working. This works in Postgresql: sqlalchemy.Column('date_created', sqlalchemy.DateTime, sqlalchemy.PassiveDefault(sqlalchemy.sql.func.now()),

[sqlalchemy] Temporary table example?

2008-04-16 Thread Gloria W
Hi again, I am looking for a good example on how to form a temporary table. I have two unrelated tables with no foreign keys. But I want to consolidate the data into a temp table and sort on their date field, to see all records chronologically from both tables. I could do it by hand in Python,

[sqlalchemy] Session binding to existing table: what am I missing?

2008-04-16 Thread Gloria W
Hi all, I am trying to use the session syntax to bind to an existing table, but I am apparently missing something. I want my session to be bound to this: my_table = sqlalchemy.Table('my_table', meta, autoload=True, autoload_with=engine) and if I use the same engine here: session =