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
As @diciu pointed out, the database file will be created by sqlite3.connect. If you want to take a special action when the file is not there, you'll have to explicitly check for existance:
import os
import sqlite3
if not os.path.exists(mydb_path):
#create new DB, create table stocks
con = sqlite3.connect(mydb_path)
con.execute('''create table stocks
(date text, trans text, symbol text, qty real, price real)''')
else:
#use existing DB
con = sqlite3.connect(mydb_path)
...