Thank you for your qick answer.
Ok i understand.
Yes it works if use:

for row in dbRH(dbRH.test.login=="Laurent").select():
    firstname = row.firstname


but the problem is that i would to use the var "auth.user.username" for my 
request and i don't know how to do

Le mercredi 16 septembre 2015 13:26:16 UTC+2, Mirek Zvolský a écrit :
>
> I don't know what SQLField() means, I use Field() instead.
>
> The variable loginsession is defined at the python level. SQL level will 
> nothing know about it.
> So you run really the SQL command: "SELECT ... WHERE login=loginsession;".
> Try same command in MySQL manager, it will not work because loginsession 
> is unkown.
>
> Do you really need run raw SQL commands (with .executesql())?
> Isn't better way use a DAL abstraction language like
>   dbRH(dbRH.test.id>0).select()
> or
>   dbRH(dbRH.test.login=="Laurent").select()
> ?
>
>
>
> Dne středa 16. září 2015 12:34:09 UTC+2 Laurent Lc napsal(a):
>>
>> Hi 
>> could you explain me why it does not work :
>> my file db.py (a part of file)
>>
>> loginsession = auth.user.username
>> dbRH = DAL('mysql://xxx:xxx@localhost/RH', pool_size=0)
>> dbRH.define_table('test',
>>     SQLField('login', type = 'string' , length = 20 ),
>>     SQLField('nom', type = 'string' , length = 20 ),
>>     SQLField('prenom', type = 'string' , length = 20 ),
>>     SQLField('groupe', type = 'string' , length = 15 ),
>>     SQLField('mail', type = 'string' , length = 50 ),
>>     migrate = False)
>> query='SELECT * from test WHERE login=loginsession'
>> firstname =dbRH.executesql(query,as_dict=True)
>>
>> If i replace the var loginsession by "toto", it works and the var 
>> loginsession has a value ...
>>
>> Another question about DAL if i follow the doc :
>> #q=dbRH.test.login==loginsession
>> #s=db(q)
>> #rows=s.select()
>> #for row in rows:
>> #    prenom = row.prenom
>>
>> does not run too ...
>>
>>
>> Thank you in advance 
>> Regards,
>>
>>
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to