2012-11-21 36 views
2

我在Linux中第一次進行web開發,稍後將其移植到嵌入式系統上,一旦它在linux機器上工作。 我有一個名爲登錄密碼在mydb數據庫中的表。我使用peewee作爲ORM進行連接。 這是我跑將mysql與peewee連接起來,以及訪問表中的某些問題

from peewee import * 
mysql_db = MySQLDatabase('mydb', user='root',passwd='rakesh') 
class Login(Model): 
    usr_name = CharField() 
    passwd = TextField() 

mysql_db.connect() 
usr = Login(usr_name="me", passwd='Peewee is cool') 
usr.save() 
for user in usr.filter(usr_name="me"): 
    print usr.title 

我已經創建了一個名爲登錄在mydb的數據庫(MySQL的)一個簡單的表腳本,它似乎是好的,當我查詢,看看

現在,當我運行這個代碼中,我得到一個異常

Traceback (most recent call last): 
    File "/home/rakesh/Ubuntu One/PDNFlywheels/PDB/access_ex.py", line 53, in <module> 
    usr.save() 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1949, in save 
    new_pk = insert.execute() 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1355, in execute 
    result = self.database.execute(self) 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1446, in execute 
    return self.execute_sql(sql, params, commit) 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1449, in execute_sql 
    cursor = self.get_cursor() 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1420, in get_cursor 
    return self.get_conn().cursor() 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1413, in get_conn 
    self.connect() 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1401, in connect 
    self.__local.conn = self._connect(self.database, **self.connect_kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1541, in _connect 
    return sqlite3.connect(database, **kwargs) 
OperationalError: unable to open database file 

,你可以在最後一行看到它嘗試使用sqllite3找到分貝,但我使用的MySQL。我不明白爲什麼會發生這種情況。 大多數peewee廚師的書籍,例子和其他解釋都使用sqllite,我從來沒有發現任何直接的mysql黑客攻擊。

回答