如果您想了解pythonsqlite3OperationalError:尝试编写只读数据库和只读属性python的知识,那么本篇文章将是您的不二之选。我们将深入剖析pythonsqlite3Opera
如果您想了解python sqlite3 OperationalError:尝试编写只读数据库和只读属性python的知识,那么本篇文章将是您的不二之选。我们将深入剖析python sqlite3 OperationalError:尝试编写只读数据库的各个方面,并为您解答只读属性python的疑在这篇文章中,我们将为您介绍python sqlite3 OperationalError:尝试编写只读数据库的相关知识,同时也会详细的解释只读属性python的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- python sqlite3 OperationalError:尝试编写只读数据库(只读属性python)
- Android:尝试编写只读数据库
- bitbake错误:sqlite3.OperationalError: unable to open database file
- D B Browser.Sqlite.OperationalError:数据库被锁定
- flask开发中遇到sqlalchemy.exc.OperationalError:(sqlite3.OperationalError) no such table:
python sqlite3 OperationalError:尝试编写只读数据库(只读属性python)
我正在尝试使用WSGI在CentOS Apache2上运行Flask
REST服务。REST服务需要非常小的存储空间。因此,我决定将SQLite与sqlite3
python软件包一起使用。整个应用程序在使用时在我的本地系统和CentOS服务器上运行良好app.run()
。但是当我使用WSGI在Apache上托管应用程序时,
OperationalError: attempt to write a readonly database
我已经检查了文件的权限。该文件的用户和组被设置为阿帕奇(在其下运行服务器),使用chown
和chgrp
。此外,该文件具有rwx
权限。仍然我收到只读数据库错误。以下是我通过ls-al
在db文件上运行得到的结果:
-rwxrwxrwx. 1 apache apache 8192 Nov 19 01:39 dbfile.db
我的Apache配置:
<VirtualHost *>ServerName wlc.host.comWSGIDaemonProcess wlcdWSGIScriptAlias / /var/www/html/wlcd.wsgiRewriteEngine onRewriteCond %{HTTP:Authorization} ^(.*)RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]<Directory /var/www/html/> WSGIProcessGroup wlcd WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all Require all granted</Directory>
答案1
小编典典除了更改数据库文件权限外,还需要更改托管数据库文件的目录的权限。您可以尝试以下命令:
chmod 664 /path/to/your/directory/
您还可以如下更改目录的所有者:
chown apache:apache /path/to/your/directory/
Android:尝试编写只读数据库
我正在使用此代码:
fileIsExists = new File(Environment.getExternalStorageDirectory() + "/bbmp/bbmp2.sqlite"); if (fileIsExists.exists()) { db = sqliteDatabase.openDatabase(fileIsExists.toString(),null,sqliteDatabase.OPEN_READWRITE); }
抛出以下错误:
10-01 17:09:17.343: E/Database(9216): DELETE Failed setting locale 10-01 17:09:17.374: E/Database(9216): Failed to setLocale() when constructing,closing the database 10-01 17:09:17.374: E/Database(9216): android.database.sqlite.sqliteException: attempt to write a readonly database 10-01 17:09:17.374: E/Database(9216): at android.database.sqlite.sqliteDatabase.native_setLocale(Native Method) 10-01 17:09:17.374: E/Database(9216): at android.database.sqlite.sqliteDatabase.setLocale(sqliteDatabase.java:1987) 10-01 17:09:17.374: E/Database(9216): at android.database.sqlite.sqliteDatabase.<init>(sqliteDatabase.java:1855) 10-01 17:09:17.374: E/Database(9216): at android.database.sqlite.sqliteDatabase.openDatabase(sqliteDatabase.java:820) 10-01 17:09:17.374: E/Database(9216): at com.pixel.bbmp2.Bbmp2Activity.checkDirectory(Bbmp2Activity.java:150) 10-01 17:09:17.374: E/Database(9216): at com.pixel.bbmp2.Bbmp2Activity.onCreate(Bbmp2Activity.java:115) 10-01 17:09:17.374: E/Database(9216): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 10-01 17:09:17.374: E/Database(9216): at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:1611) 10-01 17:09:17.374: E/Database(9216): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 10-01 17:09:17.374: E/Database(9216): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 10-01 17:09:17.374: E/Database(9216): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 10-01 17:09:17.374: E/Database(9216): at android.os.Handler.dispatchMessage(Handler.java:99) 10-01 17:09:17.374: E/Database(9216): at android.os.Looper.loop(Looper.java:123) 10-01 17:09:17.374: E/Database(9216): at android.app.ActivityThread.main(ActivityThread.java:3683) 10-01 17:09:17.374: E/Database(9216): at java.lang.reflect.Method.invokeNative(Native Method) 10-01 17:09:17.374: E/Database(9216): at java.lang.reflect.Method.invoke(Method.java:507) 10-01 17:09:17.374: E/Database(9216): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 10-01 17:09:17.374: E/Database(9216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 10-01 17:09:17.374: E/Database(9216): at dalvik.system.NativeStart.main(Native Method)
下表是数据库文件
我需要做什么?????
解决方法
bitbake错误:sqlite3.OperationalError: unable to open database file
[qc@fedora7 stuff]$ bitbake package
Traceback (most recent call last):
File "/myPart1/stuff/bitbake/bin/bitbake",line 134,in <module>
main()
File "/myPart1/stuff/bitbake/bin/bitbake",line 114,in main
cooker = bb.cooker.BBCooker(configuration)
File "/disk/zhaoshan/trunk/bitbake/lib/bb/cooker.py",line 65,in __init__
File "/disk/zhaoshan/trunk/bitbake/lib/bb/cooker.py",line 399,in parseConfigurationFile
File "/disk/zhaoshan/trunk/bitbake/lib/bb/fetch/__init__.py",line 97,in fetcher_init
File "/disk/zhaoshan/trunk/bitbake/lib/bb/persist_data.py",line 70,in delDomain
sqlite3.OperationalError: unable to open database file
磁盘空间已满的原因。因为之前还是正常工作的,也是在编译的过程中出现的错误。
D B Browser.Sqlite.OperationalError:数据库被锁定
如何解决D B Browser.Sqlite.OperationalError:数据库被锁定?
我正在尝试将表单提交到 DB browser sqlite。我已经创建了一个表。我能够将数据存储到 sqlite 中。但是,一旦我在提交按钮(submitclaim.html)中添加了一个执行确认弹出框的函数,我就会显示这个错误
sqlite3.OperationalError: database is locked
当我尝试向表格提交表单时,它发生在行上:
c.execute("INSERT INTO SubmitClaim VALUES (?,?,?)",(depart,type,uploadre,amt,description)
这是我的 app.py
@app.route(''/addrec'',methods=[''POST'',''GET''])
def addrec():
if request.method == ''POST'':
depart = request.form[''depart'']
type = request.form[''type'']
uploadre = request.form[''uploadre'']
amt = request.form[''amt'']
description = request.form[''description'']
conn = sql.connect(db_path)
c = conn.cursor()
c.execute(
"INSERT INTO SubmitClaim VALUES (?,description))
conn.commit()
c.execute("SELECT * FROM SubmitClaim")
print(c.fetchall())
conn.close()
return render_template(''base.html'',user=session["user"],version=msal.__version__)
这是我的 SubmitClaim.html
<div>
<button onclick="myFunction()" type="submit"name="save",value="save">Submit</button>
<script>
function myFunction() {
confirm("Press a button!");
}
解决方法
您只需要在 DB Browser SQLITE 中关闭数据库并运行代码
flask开发中遇到sqlalchemy.exc.OperationalError:(sqlite3.OperationalError) no such table:
flask开发中遇到sqlalchemy.exc.OperationalError:(sqlite3.OperationalError) no such table: posts [sql: 'SELECT posts.id AS posts_id,posts.body AS posts_body,posts.timestamp AS posts_timestamp,posts.author_id AS posts_author_id FROM posts ORDER BY posts.timestamp DESC']
这句话的意思是posts 这个表格不存在,解决方法查看sqlite是否存在posts表。如果不存在,在pycharm中Terminal中输入一下命令:
from app import db db.drop_all() db.create_all()
关于python sqlite3 OperationalError:尝试编写只读数据库和只读属性python的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Android:尝试编写只读数据库、bitbake错误:sqlite3.OperationalError: unable to open database file、D B Browser.Sqlite.OperationalError:数据库被锁定、flask开发中遇到sqlalchemy.exc.OperationalError:(sqlite3.OperationalError) no such table:的相关知识,请在本站寻找。
本文标签: