May-10-2018, 04:01 PM
main.py
import db setup_db() input("Press any key to continue")db.py
import sqlite3 import os def setup_db(): directory = "C:\\Users\\bi18avi\\librarydb" if not os.path.exists(directory): print("directory does not exist") os.mkdir(directory) conn = sqlite3.connect(r"C:\\Users\\bi18avi\\librarydb\\booksdb") else: print("directory exists") dbfile = "C:\\Users\\bi18avi\\librarydb\\booksdb" if not os.path.exists(dbfile): conn = sqlite3.connect(r"C:\\Users\\bi18avi\\librarydb\\booksdb")I'm running the above program on Windows 7 but it fails when I try to run the main.py script, the console box goes away so quick I can't see the error message. Note that it was working just fine when I had the db code in the main.py file running outside of a function. Any ideas as to what the problem is? Thanks.