Python连接Sqlite数据库及Django获取接收Html数据

def sqlitetest(txt,footer):
    cx = sqlite3.connect("D:\Python-Test\StuProject\db.sqlite3")
    cu = cx.cursor()
    #sql = '''insert into 'comment_comment'(txt,'footer') values (\"%s\",\"%s\");'''%(pymysql.escape_string(txt),pymysql.escape_string(footer))#字符串插入字符串sql
    sql = '''insert into 'comment_comment'(txt,'footer') values (\"%s\",\"%s\");''' % (txt, footer)  # 字符串插入字符串sql
    try:
        cu.execute(sql)
        cx.commit()
    except Exception as e:
        with open("D:\Python-Test\StuProject\dblog.txt",'a+') as f:
            log = '''执行sql发生错误:%s \n 输出:%s'''%(e,sql)
            #f.write(log)
        pass
    print(cu)

++++++++++++++++++++++++++++++++++++++++++++++++++++

cur_page = 1
def net163(request):
    global cur_page#处理报错local variable 'cur_page1' referenced before assignment
    try:
        #cur_page = int(request.GET.get('cur_page', '1'))#跳转页码
        if request.POST:
            cur_page = int(request.POST['num'])
        elif request.GET:
            cur_page = int(request.GET['cur_page'])
        else:
            print("数据传输有误")
    except ValueError:
        cur_page = 1
    pagination = Pagination.create_pagination(
            from_name='comment.models',
            model_name='comment',
            cur_page=cur_page,
            start_page_omit_symbol='...',
            end_page_omit_symbol='...',
            one_page_data_size=30,#每页显示数目
            show_page_item_len=10)#分页数目
    return render(request, 'Net163.html', {'pagination': pagination})

 

转载于:https://www.cnblogs.com/acer-haitao/p/8403562.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值