Python错误没有这样的表使用sqlite3

时间:2018-05-12 22:11:19

标签: python-3.x sqlite

今天第一次尝试使用Python,几乎立刻就被卡住了。在Windows上使用Pyhon 3.6。有人可以帮忙吗?

RESTART: C:/Users/tom_/AppData/Local/Programs/Python/Python36-32/Projects/Database/dbexample.py 
Traceback (most recent call last):
  File "C:/Users/tom_/AppData/Local/Programs/Python/Python36-32/Projects/Database/dbexample.py", line 13, in <module>
    enter_data()
  File "C:/Users/tom_/AppData/Local/Programs/Python/Python36-32/Projects/Database/dbexample.py", line 11, in enter_data
    c.execute("INSERT INTO Example VALUES('Python', 2.7, 'Beginner')")
sqlite3.OperationalError: no such table: Example

代码:

import sqlite3

conn = sqlite3.connect('tutorial.db')

c = conn.cursor()

def create_table():
    c.execute("CREATE TABLE Example(Language VARCHAR, Version REAL, Skill TEXT)")

def enter_data():
    c.execute("INSERT INTO Example VALUES('Python', 2.7, 'Beginner')")

enter_data()

conn.close()

0 个答案:

没有答案