On Friday 27 June 2008 16:55:22 [EMAIL PROTECTED] wrote:
> 1)
> "multisearch"... I meant, that i want to create piece of code, that
> will automaticly search in all columns of a table....
> So if I can use this "function" (or whatever it will be) for
> different tables with no change..
> for example:
> I have a client(table) with address(related table one-to-one) and
> persons(related table one-to-many) and make:
> clients = my_function(clients_table, 'anna')
> to return me all clients from database, 'anna' works in
thats quite a wide search - any column in any relation contains 'anna' 
or what?

> 2)
> How can I generate the "fields" in or_() statement??
for prop in class_mapper(yourclas).iterate_properties:
  ...
are all mapped props.
u may do some filtering, are they plain columns - 
isinstance(orm.properties.ColumnProperty), or relations - 
isinstance(orm.properties.PropertyLoader), and on relations, use 
prop.uselist to distinguish references from collections

> On Jun 27, 3:41 pm, [EMAIL PROTECTED] wrote:
> > what is multisearch? sort of
> > patternmatching?http://www.sqlalchemy.org/docs/05/ormtutorial.htm
> >l#datamapping_queryi...
> >
> > query(A).filter( or_(
> >     A.c1.startswith(),
> >     A.c2.endswith(),
> >     A.c3.like('%alabal%'),
> >     ...
> >   ))
> > u can generate the arguments of or_(...)
> >
> > On Friday 27 June 2008 16:12:57 [EMAIL PROTECTED] wrote:
> > > Hi.
> > >
> > > I want to do robust algorithm for searching in tables...the
> > > simplest example is with table with no relations:
> > >
> > > stmt = u'SELECT * FROM '
> > > stmt += str(b.clients.name)
> > > stmt += ' WHERE '
> > > for c in b.Client.c:
> > >   stmt += str(c)+' like \'%value%\' or '
> > >
> > > clients = session.query(Client).from_statement(stmt).all()
> > >
> > > There is one big problem using the '%' sign, because python is
> > > using it to replace values in string like:
> > > 'Welcom %s to my site' % 'john'
> > >
> > > Afterwards I want to search in tables with relations, like:
> > >
> > > session.query(Client).add_entity(Address)......
> > >
> > > Can anyone help me with this problem?
> > > What is the sqlalchemy way to make "multisearch" ??
> > >
> > > Thx in advance
> > > m_ax
>
> 


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to