• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Python错误:sqlite3.OperationalError:没有这样的表:配置

python 来源:Douglas Dias da Silva 13次浏览

我需要通过命令行更改下拉框默认文件夹(因为我需要在我的本地网络中的另一台机器上这样做,所以我将访问此通过从我的本地机器协议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

所以,球员,我需要一盏灯,任何帮助是值得欢迎的。


===========解决方案如下:

该数据库是非开源软件的内部部分。我认为Dropbox的开发人员已经掌握了数据库的结构。

在使用Dropbox的版本v16.4.30上OSX的dropbox.db文件根本不存在我的情况,使他们改变了它更


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)