Using SQLite in a Python program

后端 未结 8 740
逝去的感伤
逝去的感伤 2020-12-31 06:28

I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don\'t really know how to call it properly. All the

8条回答
  •  甜味超标
    2020-12-31 07:13

    AFAIK an SQLITE database is just a file. To check if the database exists, check for file existence.

    When you open a SQLITE database it will automatically create one if the file that backs it up is not in place.

    If you try and open a file as a sqlite3 database that is NOT a database, you will get this:

    "sqlite3.DatabaseError: file is encrypted or is not a database"

    so check to see if the file exists and also make sure to try and catch the exception in case the file is not a sqlite3 database

提交回复
热议问题