Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4468
| From | christian <ozric@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: build the "sql where cause" dynamic |
| Date | 2011-05-02 03:13 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <707c9072-6bb5-47d7-8a07-14a4175a26cf@u15g2000vby.googlegroups.com> (permalink) |
| References | <e42d849f-0433-4ce7-9e8e-5bfc7e733d0a@e21g2000vbz.googlegroups.com> <mailman.1066.1304323989.9059.python-list@python.org> |
On 2 Mai, 10:13, Chris Angelico <ros...@gmail.com> wrote:
> On Mon, May 2, 2011 at 5:48 PM, christian <oz...@web.de> wrote:
> > Hi,
>
> > from some radio buttons in a django app i concat string like that:
> > But have no idea how i get the or when there different values
> > for a specified p column (# is currently my intended splitter maybe i
> > can concat a better input?).
>
> > input: "p2=1#p2=2#p1=3#p1=1#p1=5#pc=1#py=1"
>
> > output: "p2 in ('1','2') and p1 in ('3','1','5') and pc in ('1') and
> > py in ('1')"
>
> Start by splitting the string and iterating:
> for el in input.split('#'):
>
> (obviously your variable won't want to be called 'input' but you knew
> that already)
>
> Then split on the = sign and add to a list or dictionary. Be wary of
> elements that don't have an equals sign in them.
>
> That looks like the querystring straight from the GET form, where
> you're using tickboxes. You could quite happily use '&' as your
> primary delimiter, if that's the case.
>
> Chris Angelico
Many Thanks
Christian
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
build the "sql where cause" dynamic christian <ozric@web.de> - 2011-05-02 00:48 -0700
Re: build the "sql where cause" dynamic Chris Angelico <rosuav@gmail.com> - 2011-05-02 18:13 +1000
Re: build the "sql where cause" dynamic christian <ozric@web.de> - 2011-05-02 03:13 -0700
csiph-web