Skip to content

Commit 77e598f

Browse files
committed
Checks version of SQLITE Database and shows tables in the database
This will show the current version of the SQLITE database, there are two ways it also show to display all the tables in the database
1 parent e47e636 commit 77e598f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

sqlite_check.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Script Name : sqlite_check.py
2+
# Author : Craig Richards
3+
# Created : 20 May 2013
4+
# Last Modified :
5+
# Version : 1.0
6+
7+
# Modifications :
8+
9+
# Description : Runs checks to check my SQLITE database
10+
11+
12+
import sqlite3 as lite
13+
import sys
14+
import os
15+
16+
dropbox= os.getenv("dropbox")
17+
dbfile=("Databases\jarvis.db")
18+
master_db=os.path.join(dropbox, dbfile)
19+
con = None
20+
21+
try:
22+
con = lite.connect(master_db)
23+
cur = con.cursor()
24+
cur.execute('SELECT SQLITE_VERSION()')
25+
data = cur.fetchone()
26+
print "SQLite version: %s" % data
27+
28+
29+
except lite.Error, e:
30+
31+
print "Error %s:" % e.args[0]
32+
sys.exit(1)
33+
34+
finally:
35+
36+
if con:
37+
con.close()
38+
39+
40+
con = lite.connect(master_db)
41+
cur=con.cursor()
42+
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
43+
rows = cur.fetchall()
44+
for row in rows:
45+
print row
46+
47+
con = lite.connect(master_db)
48+
cur=con.cursor()
49+
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
50+
while True:
51+
row = cur.fetchone()
52+
if row == None:
53+
break
54+
print row[0]

0 commit comments

Comments
 (0)