Skip to Content
Menu
This question has been flagged
1 Reply
2770 Views

hai, i don't know how to retrive data from database

this is my python file

         @http.route('/sample/demo', auth='public',website=True)

         def click(self, **post):

            print "post data===================>",post

            cr = request.cr

            pool = request.registry

            table_name=post.get('t_name',False)

            user_id = post.get('user_id',False)

            response_dict = {}

            jd=[]

            if user_id and table_name:

                        print"Enterloginpage======================="

                        return http.request.render('json.arun1')

            else:

                print "Invalid user_id"

                return http.request.render('json.arunkumar')

--------------------------------------------------------------------------------

    @http.route('/course/datas', auth='public',website=True)

    def index12(self, **post):

            print "post data===================>",post

            cr = request.cr

            print"==============================>"

            # cr.execute("select coursename,coursefee from course_datas")

            cr.execute("select * from table_name")

            res=cr.dictfetchall()

            print "****************",res;

            rect=[]

            if res:

                    jd = json.dumps(res)

                    print "Datas Json",jd

                    return jd

Avatar
Discard
Best Answer

hello ,

try the browse(),search() method

browes method it receive the list of  ids  

self.env['course_datas'].browes(ids)

search method receive list of tuples

self.env['course_datas'].search([('coursename','=','math')])

\
 


Avatar
Discard