[web2py] Re: SQL select with a var

2015-09-16 Thread Leonel Câmara
What do you mean it doesn't work? Can you show us how you tried to replace 
it?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL select with a var

2015-09-16 Thread Laurent Lc
like this :
myvar="toto"
for row in dbRH(dbRH.test.login==myvar).select():
firstname = row.firstname

the sql request doesn't work beacause myvar does not exist in sql but in 
python. so i don't know how to do



Le mercredi 16 septembre 2015 16:20:11 UTC+2, Leonel Câmara a écrit :
>
> What do you mean it doesn't work? Can you show us how you tried to replace 
> it?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL select with a var

2015-09-16 Thread Anthony
On Wednesday, September 16, 2015 at 10:33:39 AM UTC-4, Laurent Lc wrote:
>
> like this :
> myvar="toto"
> for row in dbRH(dbRH.test.login==myvar).select():
> firstname = row.firstname
>
> the sql request doesn't work beacause myvar does not exist in sql but in 
> python. so i don't know how to do
>

Yes, myvar is a Python variable, but then again, it is being used in Python 
code, so no problem there. The DAL will convert that to the appropriate SQL 
statement. Are you sure that is your *exact* code? How are you determining 
whether it "works"? I suspect you have a problem elsewhere.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL select with a var

2015-09-16 Thread Laurent Lc
yes copy/paste
it works because in the view associated i can see the var "firstname"

Le mercredi 16 septembre 2015 16:48:19 UTC+2, Anthony a écrit :
>
> On Wednesday, September 16, 2015 at 10:33:39 AM UTC-4, Laurent Lc wrote:
>>
>> like this :
>> myvar="toto"
>> for row in dbRH(dbRH.test.login==myvar).select():
>> firstname = row.firstname
>>
>> the sql request doesn't work beacause myvar does not exist in sql but in 
>> python. so i don't know how to do
>>
>
> Yes, myvar is a Python variable, but then again, it is being used in 
> Python code, so no problem there. The DAL will convert that to the 
> appropriate SQL statement. Are you sure that is your *exact* code? How 
> are you determining whether it "works"? I suspect you have a problem 
> elsewhere.
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: SQL select with a var

2015-09-16 Thread Laurent Lc
you were right, it was not exactly the same code.
Now i put the code in db.py, and i use the request to set default values in 
a form. Is it a good way ?

Le mercredi 16 septembre 2015 16:48:19 UTC+2, Anthony a écrit :
>
> On Wednesday, September 16, 2015 at 10:33:39 AM UTC-4, Laurent Lc wrote:
>>
>> like this :
>> myvar="toto"
>> for row in dbRH(dbRH.test.login==myvar).select():
>> firstname = row.firstname
>>
>> the sql request doesn't work beacause myvar does not exist in sql but in 
>> python. so i don't know how to do
>>
>
> Yes, myvar is a Python variable, but then again, it is being used in 
> Python code, so no problem there. The DAL will convert that to the 
> appropriate SQL statement. Are you sure that is your *exact* code? How 
> are you determining whether it "works"? I suspect you have a problem 
> elsewhere.
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.