Python中的SQLITE不是创建表而是创建数据库

时间:2016-11-19 23:06:55

标签: python database sqlite

我正在尝试连接到SQLITE数据库,似乎代码确实创建了数据库,但是它不会创建表,也不会在其中插入任何内容(很可能是因为它们从未创建过) 我有SQLite数据库浏览器,在其中我打开数据库,但没有任何表或任何东西。另外,我在项目旁边的文件夹中看到了我的数据库。

我有以下代码:

import sqlite3
conn = sqlite3.connect("dfg.db")
c = conn.cursor()

def create_tabe():
    c.execute('CREATE TABLE IF NOT EXISTS tabl(city TEXT, temp REAL)')

def data_entry():
    c.execute("INSERT INTO tabl VALUES ('dasfsd', 32434)")
    conn.commit()
    c.close()
    conn.close()

0 个答案:

没有答案