Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Source Code Optimization #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/whatsapp-osint.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions db_to_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,3 @@ def db_to_excel(self):

except PermissionError:
print("Please Close Your Excel File and restart ")


21 changes: 14 additions & 7 deletions utils/database.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import sqlite3


class Database():
def create_table():
conn = sqlite3.connect('database/database.db')
c = conn.cursor()
c.execute("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='Connections'")
table_exists = c.fetchone()[0]
if not table_exists:
c.execute('CREATE TABLE Connections (id INTEGER PRIMARY KEY AUTOINCREMENT, user_name TEXT, date TEXT, hour TEXT, minute TEXT, second TEXT, type_connection TEXT, time_connected TEXT)')
c.execute(
'CREATE TABLE Connections (id INTEGER PRIMARY KEY AUTOINCREMENT, user_name TEXT, date TEXT, hour TEXT, minute TEXT, second TEXT, type_connection TEXT, time_connected TEXT)')
conn.commit()
conn.close()

def insert_connection_data(name, date, hour, minute, second, type_connection):
def insert_connection_data(self, date, hour, minute, second, type_connection):
conn = sqlite3.connect('database/database.db')
c = conn.cursor()
c.execute('INSERT INTO Connections (user_name, date, hour, minute, second, type_connection) VALUES (?, ?, ?, ?, ?, ?)', (name, date, hour, minute, second, type_connection))
c.execute(
'INSERT INTO Connections (user_name, date, hour, minute, second, type_connection) VALUES (?, ?, ?, ?, ?, ?)',
(self, date, hour, minute, second, type_connection),
)
conn.commit()
conn.close()

def insert_disconnection_data(name, date, hour, minute, second, type_connection, time_connected):
def insert_disconnection_data(self, date, hour, minute, second, type_connection, time_connected):
conn = sqlite3.connect('database/database.db')
c = conn.cursor()
c.execute('INSERT INTO Connections (user_name, date, hour, minute, second, type_connection, time_connected) VALUES (?, ?, ?, ?, ?, ?, ?)', (name, date, hour, minute, second, type_connection, time_connected))
c.execute(
'INSERT INTO Connections (user_name, date, hour, minute, second, type_connection, time_connected) VALUES (?, ?, ?, ?, ?, ?, ?)',
(self, date, hour, minute, second, type_connection, time_connected),
)
conn.commit()
conn.close()

conn.close()
Loading