jjzjj

ProgrammingError

全部标签

python - sqlite3.ProgrammingError : You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings

在Python中使用SQLite3,我正在尝试存储UTF-8HTML代码片段的压缩版本。代码如下:...c=connection.cursor()c.execute('createtableblah(cidintegerprimarykey,htmlblob)')...c.execute('insertorignoreintoblahvalues(?,?)',(cid,zlib.compress(html)))在什么时候得到错误:sqlite3.ProgrammingError:Youmustnotuse8-bitbytestringsunlessyouuseatext_factory

python - sqlite3.ProgrammingError : You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings

在Python中使用SQLite3,我正在尝试存储UTF-8HTML代码片段的压缩版本。代码如下:...c=connection.cursor()c.execute('createtableblah(cidintegerprimarykey,htmlblob)')...c.execute('insertorignoreintoblahvalues(?,?)',(cid,zlib.compress(html)))在什么时候得到错误:sqlite3.ProgrammingError:Youmustnotuse8-bitbytestringsunlessyouuseatext_factory

python - ProgrammingError : (1146, "Table ' test_<DB>.<TABLE >' doesn' t exist") 为 Django 运行单元测试时

我正在使用Django框架运行单元测试并收到此错误。运行实际代码没有这个问题,运行单元测试会即时创建一个测试数据库,所以我怀疑问题出在那里。抛出错误的代码如下所示member=Member.objects.get(email=email_address)模型看起来像classMember(models.Model):member_id=models.IntegerField(primary_key=True)created_on=models.DateTimeField(editable=False,default=datetime.datetime.utcnow())flags=mo

python - "django.db.utils.ProgrammingError: relation "app_user "does not exist"在 manage.py 测试期间

我的设置:Django1.8.3python2.7.10Ubuntu14.04django-two-factor-auth==1.2.0当我运行pythonmanage.pytest时出现以下错误:Traceback(mostrecentcalllast):File"/src/venv/bin/django-admin.py",line5,inmanagement.execute_from_command_line()File"/src/venv/lib/python2.7/site-packages/django/core/management/__init__.py",line33

python - pysqlite2 : ProgrammingError - You must not use 8-bit bytestrings

我目前出于自己的目的将文件名保存在sqlite数据库中。每当我尝试插入具有特殊字符(如é等)的文件时,它都会抛出以下错误:pysqlite2.dbapi2.ProgrammingError:Youmustnotuse8-bitbytestringsunlessyouuseatext_factorythatcaninterpret8-bitbytestrings(liketext_factory=str).ItishighlyrecommendedthatyouinsteadjustswitchyourapplicationtoUnicodestrings.当我通过使用unicode方法

python - 解决 "django.db.utils.ProgrammingError: permission denied for relation django_migrations"的步骤

有哪些基本步骤可以排除Django的“django.db.utils.ProgrammingError:permissiondeniedforrelationshipdjango_migrations”错误的原因?在最初是一个稳定的生产服务器之后,我收到了这条消息,但后来对Django、Postgres、Apache和Github的几个方面进行了一些更改。此外,这些更改已经有一段时间了,我不记得或无法跟踪可能导致问题的每一个更改。我在运行pythonmanage.pyrunserver或任何其他pythonmanage.py...命令时收到消息,除了pythonmanage.pyche

python - django.db.utils.ProgrammingError : relation already exists

我正在尝试为一个新的django项目设置表(即,这些表在数据库中尚不存在);django版本是1.7,db后端是PostgreSQL。该项目的名称是crud。迁移尝试的结果如下:pythonmanage.pymakemigrationscrudMigrationsfor'crud':0001_initial.py:-CreatemodelAddressPoint-CreatemodelCrudPermission-CreatemodelCrudUser-CreatemodelLDAPGroup-CreatemodelLogEntry-Addfieldldap_groupstocrudu

python - sqlite3.ProgrammingError : Incorrect number of bindings supplied. 当前语句使用1,提供了74个

definsert(array):connection=sqlite3.connect('images.db')cursor=connection.cursor()cnt=0whilecnt!=len(array):img=array[cnt]print(array[cnt])cursor.execute('INSERTINTOimagesVALUES(?)',(img))cnt+=1connection.commit()connection.close()我不知道为什么这给了我错误,我尝试插入的实际字符串是74个字符长,它是:“/gifs/epic-fail-photos-there

python - sqlite3.ProgrammingError : Incorrect number of bindings supplied. 当前语句使用1,提供了74个

definsert(array):connection=sqlite3.connect('images.db')cursor=connection.cursor()cnt=0whilecnt!=len(array):img=array[cnt]print(array[cnt])cursor.execute('INSERTINTOimagesVALUES(?)',(img))cnt+=1connection.commit()connection.close()我不知道为什么这给了我错误,我尝试插入的实际字符串是74个字符长,它是:“/gifs/epic-fail-photos-there
12