This question has been flagged
2 Replies
6723 Views

hi,

what mean the param cr in some or all orm osv functions

thanks in advance

Avatar
Discard
Best Answer

Hello Zouhair,

Cr means a "cursor"  which is the concept of SQL. The role of cursor(cr in Odoo) is to enumerate/iterate over each rows in result set one by one.
Hence cursor  act like a looping statement to fetch  data row by row basis

Enough of theory now , lets take an simple example of sql:

import psycopg2

conn = psycopg2.connect(database="mydb", user="postgres", password="postgres", host="127.0.0.1", port="5432")

cur = conn.cursor()  #cursor object is created

cur.execute('''select name,date_order from sale.order''')

rows = cur.fetchall()

cur.close()

 

 

Avatar
Discard
Best Answer

Hi, the cr parameters is a cursor to the database,

you can see the class here : https://github.com/odoo/odoo/blob/master/openerp/sql_db.py#L75.

As the class description says it's a wrapper around a psycopg cursor.

Avatar
Discard