简体   繁体   English

数据库脚本中的f.read()上的utf错误

[英]utf error on f.read()) in database script

im working on one of my first bigger python flask web projects and im getting this error when im trying to compile: C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\Extensions\\Microsoft\\Python Tools for Visual Studio\\2.2\\visualstudio_py_debugger.py:497: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal handlers = self.handler_cache.get(filename) with this error and since im using visual studios to develop in, i get the breakpoint here: 我在我的第一个更大的python烧瓶web项目之一工作,我正在尝试编译时收到此错误: C:\\ Program Files(x86)\\ Microsoft Visual Studio 12.0 \\ Common7 \\ IDE \\ Extensions \\ Microsoft \\ Python工具的Visual Studio \\ 2.2 \\ visualstudio_py_debugger.py:497:UnicodeWarning:Unicode等同比较无法将两个参数都转换为Unicode - 将它们解释为不等处理程序= self.handler_cache.get(filename)并出现此错误,因为即时通讯使用可视工作室进行开发,我在这里得到断点:

def init_db():
with app.app_context():
    db = get_db()
    with app.open_resource('schema.sql',mode='r') as f:
        db.cursor().executescript(f.read()) //ERROR on last )
    db.commit()

as im quiet new to python in general ive tried to look for a spesific answer, but cant find one that solves the problem. 因为我很安静新来的python一般我试图寻找一个特定的答案,但无法找到一个解决问题。 my imports are: 我的进口是:

# -*- coding: utf-8 -*- 
   from datetime import datetime
   from FlaskWebProject2 import app
   import sqlite3
   from flask import Flask, request, g, redirect, url_for, abort, render_template, flash, jsonify

Found the error. 发现错误。

Was caused by a , mistake in the sql file which causes the database script to crash while initializing 是由于sql文件中的错误导致数据库脚本在初始化时崩溃造成的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM