我需要通过命令行更改下拉框默认文件夹(因为我需要在我的本地网络中的另一台机器上这样做,所以我将访问此通过从我的本地机器协议SSH)到另一个文件夹的机器,我在互联网搜索和解决的办法是在所有的,我觉得,用这个python脚本相同:Python错误:sqlite3.OperationalError:没有这样的表:配置
> #!/usr/bin/env
> # Script for showing or setting the dropbox folder.
> #
> # Execute without options to show current dropbox folder (if non-default).
> # Execute with --setfolder=/foo/bar to set new dropbox folder.
> #
> # I dedicate this work to the public domain by waiving all my rights to the
> # work worldwide under copyright law, including all related and neighboring
> # rights, to the extent allowed by law.
> #
> # You can copy, modify, distribute and perform the work, even for commercial
> # purposes, all without asking permission.
> #
> # Wim Coenen ([email protected]).
import base64
import optparse
import os
import os.path
import sqlite3
# parse command line options
cmdparser = optparse.OptionParser()
cmdparser.add_option("-s","--setfolder", dest="folder",
help="set dropbox folder")
(options, args) = cmdparser.parse_args()
db_path = os.path.expanduser("~/.dropbox/dropbox.db")
db = sqlite3.connect(db_path)
cursor = db.cursor()
# get dropbox_path
cursor.execute("select value from config where key='dropbox_path'")
dropbox_path = "<default>"
for entry in cursor:
dropbox_path_base64 = entry[0]
dropbox_path_raw = base64.decodestring(dropbox_path_base64)
dropbox_path = dropbox_path_raw[1:-5]
print "current dropbox path: %s" % dropbox_path
if not options.folder is None:
new_path_raw = "V" + os.path.abspath(options.folder) + "\np1\n."
new_path_base64 = base64.encodestring(new_path_raw)
cursor.execute("delete from config where key='dropbox_path'")
cursor.execute("insert into config (key,value) values (?,?)", \
("dropbox_path", new_path_base64))
db.commit()
print "new dropbox path: %s" % options.folder
db.close()
这里是教程链接我遵循:https://whatbox.ca/wiki/Dropbox
所以,我很新手与python,当我尝试执行此脚本
python ~/Downloads/dropboxdir.py --setfolder=/home/user/new_folder
他returnd此错误:
cursor.execute("select value from config where key='dropbox_path'")
sqlite3.OperationalError: no such table: config
所以,球员,我需要一盏灯,任何帮助是值得欢迎的。
你有一个数据库,并且在其上运行的脚本。并且错误报告数据库里面没有表“配置”。我们如何解决这个问题?该问题驻留在缺少所需表的数据库中。 – aronadaal
@aronadaal嗯,我很理解...那么我能做些什么添加此表? –
您可以通过create table命令添加w表,但dropbox似乎已经chnaged – Mark