简体   繁体   中英

Why I cannot use database created and filled by sqlite3?

I had a dump *.sql file of some database. I took a recipe of reading from here . Briefly, I create empty database, fill it in from the commands in the *.sql file and run some sql command to check it worked, close the database. When I reopen the databse it seems to be empty:

conn = sqlite3.connect('mine.db') #create empty database
c = conn.cursor() #coursor for the databse
fd = open('file.sql', 'r')
sqlFile = fd.read()
fd.close()
sqlCommands = sqlFile.split(';')
for command in sqlCommands:
   #here read *.sql into my database..if I understood correctly
   c.execute(command)
result = c.execute("SELECT * FROM phenotype;",conn)

But when I open my database again and try to execute sql command it says that there is no such table

    conn = sqlite3.connect('mine.db') #create empty database
    c = conn.cursor() #coursor for the databse
    result = c.execute("SELECT * FROM phenotype;",conn)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM