Making it Pythonic: create a sqlite3 database if it doesn't exist?

Viewed 27823

I wrote a Python script which initializes an empty database if it doesn't exist.

import os

if not os.path.exists('Database'):
    os.makedirs('Database')
    os.system('sqlite3 Database/testDB.db ";"')

# rest of the script...

Can I do this in a more Pythonic fashion, with a try-except, or is this kind of code acceptable?

4 Answers
Related