Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
82 views
in Technique[技术] by (71.8m points)

python - Table is not creating

I am making little project with sqlite3, but table is not creating.

import sqlite3

conn = sqlite3.connect("test.sqlite")
c = conn.cursor()

c.execute('''CREATE TABLE students
             (rollno real, name text, class real)''')
            
        
conn.commit()
#close the connection
conn.close()


see photo

question from:https://stackoverflow.com/questions/65646434/table-is-not-creating

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is not a code error.

Please navigate to where you have the python file running/saved in the DB browser. File -> Open Database and select the test.sqlite file. You will then see something like this:

enter image description here

Code used:

import sqlite3

conn = sqlite3.connect("test.sqlite")
c = conn.cursor()

c.execute('''CREATE TABLE students
             (rollno real, name text, class real)''')
            
        
conn.commit()
#close the connection
conn.close()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...