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

时间:2017-01-02 13:13:59

标签: python ubuntu dropbox

我需要通过命令行更改下拉框默认文件夹(因为我需要在本地网络中的另一台机器上执行此操作,因此我将通过本地计算机上的协议ssh访问此计算机)到另一个文件夹,我在互联网上搜索,解决方案与我找到的相同,使用这个python脚本:

> #!/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 (wcoenen@gmail.com).

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

他回复了这个错误:

  

cursor.execute(&#34;从配置中选择值,其中key =&#39; dropbox_path&#39;&#34;)

     

sqlite3.OperationalError:没有这样的表:config

所以伙计们,我需要一盏灯,欢迎任何帮助。

1 个答案:

答案 0 :(得分:0)

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

在我的情况下,在OSX上使用dropbox版本v16.4.30,dropbox.db文件甚至不存在,所以他们更改了它