-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
408 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sqlite3 as lite | ||
from imports import globals | ||
import sys | ||
|
||
|
||
class DBHandler: | ||
|
||
def __init__(self): | ||
try: | ||
self.con = lite.connect(globals.vars.db_path) | ||
self.cur = self.con.cursor() | ||
except lite.Error as e: | ||
print "An error occurred:", e.args[0] | ||
sys.exit() | ||
|
||
def get_full_details(self): | ||
return self.cur.execute("SELECT * FROM Malwares").fetchall() | ||
|
||
def get_partial_details(self): | ||
return self.cur.execute("SELECT ID, TYPE, LANGUAGE, ARCHITECTURE, PLATFORM, NAME FROM Malwares").fetchall() | ||
|
||
def get_mal_names(self): | ||
# Sqlite3 returns a tuple even if a single value is returned | ||
# We use x[0] for x to unpack the tuples | ||
return [val[0] for val in self.cur.execute("SELECT NAME FROM Malwares").fetchall()] | ||
|
||
def query(self, query, param=''): | ||
try: | ||
return self.cur.execute(query, param).fetchall() | ||
except lite.Error as e: | ||
print "An error occurred:", e.args[0] | ||
sys.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
0e96c3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful!
0e96c3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, nice work !