我只想使用游标在烧瓶中创建分页,但我真的不知道该怎么做,因为我发现的其他解决方案非常复杂,我很难实现它。这里有人可以帮我吗?这是我的简单代码@web_initials.route('/webpage/gmsi/list_of_users', defaults={'page': 1})@web_initials.route('/webpage/gmsi/list_of_users/<page>')@login_requireddef list_of_users(page): conn2 = psycopg2.connect(database='mydb', user='myuser', host='myhost.host', password='mypassword') cur2 = conn2.cursor() cur2.execute('SELECT count(*) FROM tbl_users') x = [dict(((cur2.description[i][0]), value) for i, value in enumerate(row)) for row in cur2.fetchall()] data2 = x[0]['count'] conn = psycopg2.connect(database='mydb', user='myuser', host='myhost.host', password='mypassword') cur = conn.cursor() cur.execute('SELECT tbl_users.tbluserid, CONCAT(firstname,\' \', middle_initial, \' \', lastname) AS \"FULL NAME\", tbl_single_role.userrole, image_path, tbl_single_role.tblsingleroleid FROM tbl_users INNER JOIN tbl_single_role ON tbl_users.tblsingleroleid = tbl_single_role.tblsingleroleid ORDER BY lastname ASC LIMIT {limit} offset {offset}'.format(limit = 5, offset = 0)) data = cur.fetchall() page = request.args.get(get_page_parameter(), type=int, default=1) pagination = Pagination(page, total=data2, css_framework='bootstrap4', record_name='users') return render_template('tables.html', data = data, pagination=pagination)这是我的 html{{ pagination.info }} {{ pagination.links }} <div class="table-responsive"> <table class="table"> <thead class=" text-primary"> <th> Full Name </th> <th> Photo </th> </thead> <tbody> {% for item in data %} <tr>
添加回答
举报
0/150
提交
取消