0

I am new to sqlalachemy in python and i have a question. I need to port this query:

UPDATE user_list SET last_visit=now()  WHERE   name='"+username+"'

I have read a lot about the update query, but I see possibility to set the value of the last_visit to the value generated by the now() function of postgresql. How would I do that properly? Assume that I would use the update functions of sqlalachemty. I could generate this as sql string and execute() it, but then the statement could be subject of sql injection. How to do this right?

1 Answer 1

1

You can use func.now() (import func from sqlalchemy).

Reference: http://docs.sqlalchemy.org/en/latest/core/functions.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.