We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ec17cc commit e6b3602Copy full SHA for e6b3602
easydb/__init__.py
@@ -3,11 +3,12 @@
3
4
class EasyDB:
5
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:
+ exists = os.path.exists(filename)
+ if !exists and !schema:
9
raise Exception, "The specified database file does not exist, and you haven't provided a schema"
10
- else:
+
+ self.connection = sqlite3.connect(filename)
11
+ if !exists:
12
for table_name, fields in schema.items():
13
query = "CREATE TABLE %s (%s)" % (table_name, ", ".join(fields))
14
self.query(query)
0 commit comments