Skip to content

Commit 63aaffa

Browse files
authored
Create no_commit.py
1 parent 6bd80fc commit 63aaffa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

no_commit.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/python
2+
3+
import sqlite3
4+
import sys
5+
6+
con = None
7+
8+
try:
9+
con = sqlite3.connect('ydb.db')
10+
11+
cur = con.cursor()
12+
cur.execute("DROP TABLE IF EXISTS friends")
13+
cur.execute("CREATE TABLE friends(id INTEGER PRIMARY KEY, name TEXT)")
14+
cur.execute("INSERT INTO friends(name) VALUES ('Tom')")
15+
cur.execute("INSERT INTO friends(name) VALUES ('Rebecca')")
16+
cur.execute("INSERT INTO friends(name) VALUES ('Jim')")
17+
cur.execute("INSERT INTO friends(name) VALUES ('Robert')")
18+
19+
#con.commit()
20+
21+
except sqlite3.Error as e:
22+
23+
if con:
24+
con.rollback()
25+
26+
print(e)
27+
sys.exit(1)
28+
29+
finally:
30+
31+
if con:
32+
con.close()

0 commit comments

Comments
 (0)