[sqlalchemy] sqlalchemy introspection How?

2007-04-27 Thread johnny

I have tables created using another orm.  I just want to know, how I
can create sqlalchemy classes based on the tables, that are already
there in the database?

Thank you


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: MemoryError in unitofwork.py

2007-04-27 Thread Brandon Goldfedder

Okay - next dump quesion: How do I clear out the objects in a session
that I no longer need to reference (in this case all of them)... Will
python GC take care of this?

--Brandon

On Apr 25, 7:15 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Apr 24, 2007, at 10:59 AM,BrandonGoldfedder wrote:



  I'm doing a fair number of session flushes as I update my data in the
  database. After about 53 of them (or so) I am getting the following
  exception:

File build\bdist.win32\egg\sqlalchemy\orm\session.py, line 294, in
  flush
File build\bdist.win32\egg\sqlalchemy\orm\unitofwork.py, line 181,
  in flush
  MemoryError

  Anyone have any ideas:
  My code is simply adding new entries and every 1000 entries flushing
  the objectstore.

 the session doesnt clear itself out after a flush, so with each  
 successive save() of objects memory will grow.


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: SQLAlch. + ODBC + DBISAM... :-(

2007-04-27 Thread Rick Morrison
I'd be happy to host a buildslave here on a VM. AFAIK, the buildslaves
connect outbound to the master, which would work for me. As far as hosting
the master, I dunno -- we're out here in the hinterlands of Connecticut in
dynamic IP address land for now.


On 4/27/07, Michael Bayer [EMAIL PROTECTED] wrote:



 On Apr 26, 2007, at 6:31 PM, Rick Morrison wrote:

  Sounds like a great idea -- is there an existing buildbot master to
  tie into, or will the whole thing be new?
 

 well my limited understanding of buildbots says that we would need to
 make one that responds to SQLAlchemy version changes, since the
 main one at pybots.org responds only to Python builds ?  also it
 requires a persistent running service that is always connected to the
 master (which i feel is overkill), but we'd have to determine hosting
 for the whole thing.



 


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Multiple inheritance and relations

2007-04-27 Thread Michael Bayer


On Apr 27, 2007, at 11:17 AM, Dave Harrison wrote:


 Hi all,

 I've got a situation where I have a table of data that is common,  
 with the
 subtables just adding an extra couple of fields.  Using multiple  
 inheritance I
 fit it together as below (pretty much the same as the documented  
 example).

 What I'm having problems with is then accessing those child tables  
 as properties
 of the person table mapping.  I'm get the following error,

 
 Cant determine relation direction for 'example' on mapper 'Mapper| 
 Person|person'
 with primary join 'person.id = example.person_id' - foreign key  
 columns are not
 present in neither the parent nor the child's mapped
 tablesset([Column('person_id',Integer(),ForeignKey('person.id'))])
 



the surprise here is that you established the relationship to the  
subclass, when the join condition is expressed in the superclass'  
table.  theres all kinds of logic that is limiting the search for  
joins and foreign key relationships to between just the local  
tables (i.e. not to the joined inherited/inheriting tables) since we  
have a lot of test cases with very intricate self-referential  
relationships that blow up easily.  so this innocent example led to  
the need to make all those searches look in both places separately  
and pick the one that fits better.  this is in r2564.

 P.S that error should read foreign key columns are present in  
 neither ...

also in r2564.


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Problem with clear_mapper

2007-04-27 Thread Kevin Schmidt

 I can use clear_mappers() because I use mod_python and my mappers
 are defined
 during init. Is there any other way I can get this select mapped to
 my object?

 non_primary=True  (see the docs on mutliple mappers for a class)
 But that would mean I would define a new non_primary mapper every  
 time,
 wouldn't it? Is this really a good idea for a server software?
 Is there maybe a way to update the used table without redefining  
 the mapper?

 
 if you are creating all kinds of select() objects from which you want  
 to load instances, simply feed those into query.select() and the  
 appropriate instances will be returned (or use query.instances()   
 with the result of execute()).

Thanks, that worked great.

Bye,
Kevin


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] SQLAlchemy at OSCON

2007-04-27 Thread Jonathan Ellis

As I understand it, the schedule is still tentative at this point, but
the fact that I'll get to teach a SQLAlchemy tutorial is not.  (Like
my PyCon tutorial, this will be aimed at those who have not yet used
SA.)

O'Reilly Open Source Convention 2007 at the Oregon Convention Center
in Portland, Oregon, July 23-27:

- Tutorial
 Title: SQLAlchemy: Taming ORM with Python
 Date: 07/24/2007
 Time: 1:30pm to 5:00pm

--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: [Sqlalchemy-users] Objects with just some fields

2007-04-27 Thread Mike Orr

On 4/27/07, Michael Bayer [EMAIL PROTECTED] wrote:

 On Apr 27, 2007, at 2:19 PM, Mike Orr wrote:

  Is it possible to make a mapper class that loads  modifies only some
  fields in a table rather than all the fields, yet still autoloads the
  fields rather than having hardcoded column types?

 you want to use a deferred column :

 http://www.sqlalchemy.org/docs/
 adv_datamapping.html#advdatamapping_properties_deferred

That puts the burden in the wrong place: (1) I have to list all the
undesired columns by name, (2) SQLAlchemy has to go to the trouble of
making it a deferred column when I'd prefer it just ignore it
entirely.

 yeah when you map to a select, it treats that like a table, and
 selects from it so that it can be manipulated similarly.

Is it safe to do updates on an object mapped to a select?  E.g.,

_sel = select([... fields ...])
class Foo(object):  pass
mapper(Foo, _sel)
for i in session.query(Foo).select():
i.attr = Value
session.flush()

  What I'd like to do is pass a list of column names to the Table
  constructor and have it autoload those and ignore the others.  I
  couldn't find an argument for this.

 oh.  well that we haven't done yet.  the usual use case is that if
 you know the names of the columns already, why reflect them ?  but
 yes i understand the advantage of getting the data types and foreign
 key constraints reflected.  this wouldnt be a difficult feature to add.

Created ticket #561 suggesting:

Table(Foo, meta, autoload_columns=[foo_id, col2, col3])

  - Is there a supported way to add/remove fields from a query after
  it's been constructed?

 from a select(), it supports adding things.  there is append_column
 (), append_whereclause(), order_by(), etc.  this API needs docstrings
 and probably the names order_by/group_by should be named
 append_order_by() etc.but you can see the methods listed out in
 the HTML docstrings on the site (html docs also included with the dist).

 removing things is not stressed so much since the typical use case is
 building up a query from a core criterion/selectable, and we have
 the usual issue about decisions being made based on things being
 appended, which to support removal would mean a lot of new code
 (which id welcome, of course !) to support un-making those decisions.

.append_column just needs to be documented in the manual.
.remove_column would be useful, but it's not that important if it's
complicated to implement.  (I thought the column list was just a
simple list until the query was compiled.)  I wasn't suggesting
.remove_whereclause or .remove_order_by -- I don't see any point for
those, and how would one identify the element to remove anyway?

-- 
Mike Orr [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Using MAX in a relation() without an inner SELECT

2007-04-27 Thread Brian Beck

Hi,

We've got a CMS model with a revisioned page tree. Our pages have a
revision number and a parent page (it's a self-referential mapper).
One property we'd like to have in our assign_mapper call is a
latest_parent relation -- a property that returns the page with
page_id = parent_id and revision_number = MAX revision_number for that
page_id.

We've isolated our case into a simple example, where our table looks
like this:

pages_table = Table('pages', metadata,
Column('page_id', Integer, primary_key=True),
Column('revision_number', Integer, primary_key=True),
Column('parent_id', Integer, ForeignKey('pages.page_id'),
nullable=True),
)

We got the property working in the following complete example:
http://dpaste.com/hold/9205/

However, the query generated by that relation has 2 SELECTs, and the
result we want is possible with a single, very simple SELECT (using
page_id = 3 as an example):

SELECT *, MAX(pages.revision_number) FROM pages WHERE pages.page_id =
3

...and we can (sort-of) accomplish this in SQLAlchemy with this
select():

select([*, func.max(pages_table.c.revision_number)],
pages_table.c.page_id == 3)

However, that returns the tuple given by dbapi and not an instance of
the mapped class. We also can't figure out how to get this behavior in
a relation(), so that just the above SELECT is executed and not nested
SELECTs (as in the pasted example).

Is there some other kind of MapperProperty besides relation that will
let us do this? Any help is appreciated.

Brian Beck / Adventurer of the First order / www.brianbeck.com


--~--~-~--~~~---~--~~
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 PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---