Welcome!

This community is for professionals and enthusiasts of our products and services.Share and discuss the best content and new marketing ideas,build your professional profile and become a better marketer together.

Register
1

How can I use direct SQL queries?

By
Diogo Duarte
on 11/4/15, 9:55 PM1370 views

How can I execute custom SQL queries?


0
Diogo Duarte
On11/4/15, 9:57 PM

The cr attribute on environments is the cursor for the current database transaction and allows executing SQL directly (e.g. for queries which are difficult to express using the ORM or for performance reasons). You can use "self.env.cr.execute('SELECT * FROM table WHERE attribute=%s', [(value)])" and fetch the results in a for cycle by doing "for results in self.env.cr.dictfetchall():".


Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, justuse the commenting tool. Please remember that you can alwaysrevise your answers - no need to answer the same question twice. Also, pleasedon't forget to vote - it really helps to select the best questions and answers!

Keep Informed

About This Community

This community is for professionals and enthusiasts of our products and services.Share and discuss the best content and new marketing ideas,build your professional profile and become a better marketer together.

Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/4/15, 9:55 PM
Seen: 1370 times
Last updated: 11/5/15, 1:25 AM