Skip to content

Commit e6b3602

Browse files
committed
Update __init__.py
1 parent 2ec17cc commit e6b3602

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

easydb/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
class EasyDB:
55
def __init__(self, filename, schema = None, **kwargs):
6-
if os.path.exists(filename) or schema:
7-
self.connection = sqlite3.connect(filename)
8-
elif not schema:
6+
exists = os.path.exists(filename)
7+
if !exists and !schema:
98
raise Exception, "The specified database file does not exist, and you haven't provided a schema"
10-
else:
9+
10+
self.connection = sqlite3.connect(filename)
11+
if !exists:
1112
for table_name, fields in schema.items():
1213
query = "CREATE TABLE %s (%s)" % (table_name, ", ".join(fields))
1314
self.query(query)

0 commit comments

Comments
 (0)