2017-01-02 50 views
0

我需要通過命令行更改下拉框默認文件夾(因爲我需要在我的本地網絡中的另一臺機器上這樣做,所以我將訪問此通過從我的本地機器協議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

所以,球員,我需要一盞燈,任何幫助是值得歡迎的。

+1

你有一個數據庫,並且在其上運行的腳本。並且錯誤報告數據庫裏面沒有表「配置」。我們如何解決這個問題?該問題駐留在缺少所需表的數據庫中。 – aronadaal

+0

@aronadaal嗯,我很理解...那麼我能做些什麼添加此表? –

+0

您可以通過create table命令添加w表,但dropbox似乎已經chnaged – Mark

回答

0

該數據庫是非開源軟件的內部部分。我認爲Dropbox的開發人員已經掌握了數據庫的結構。

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

+0

您是指sqlite3的開發人員? –

相關問題