Base sqlite DB

master
Tim 3 years ago
parent e75ecb877d
commit fc14419175
  1. 2
      .gitignore
  2. 42
      util_db.py

2
.gitignore vendored

@ -0,0 +1,2 @@
__pycache__
\*.db

@ -0,0 +1,42 @@
#!/usr/bin/env python
import sqlite3
db_file = "plugin-vuln.db"
class db_sqlite():
def __init__(self):
self.db_file = db_file
self.conn = sqlite3.connect(db_file)
def add_plugin(self, plugin):
try:
name = plugin["plugin"]
version = plugin["version"]
if self.check_plugin(name, version):
print("Plugin: " + name + "Exists Already")
temp_plugin = (name, version)
self.conn.execute('INSERT INTO plugin VALUES (?,?)', temp_plugin)
self.conn.commit()
except Exception:
raise NameError
print(name, version)
def check_plugin(self, plugin_name, plugin_version):
plugin = (plugin_name, plugin_version)
data = self.conn.execute('select * from plugin where name=? AND version=?', plugin)
if data:
return (True, "plugin exists")
else:
return (False, "not in database")
def cleanup(self):
self.conn.commit()
self.conn.close()
try:
conn.execute("create table plugin(name, version)")
except Exception:
print("DB Already Exists")
Loading…
Cancel
Save