Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit cf13537

Browse files
committed
Integration of OOP for easiest database queries and easiest connection for a begginer-friendly setting: 0.3
1 parent fb4aaa3 commit cf13537

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

projects/DatabaseConnectionWithOOP/classes.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
# Abstract Classes
55
class AbstractDatabase(ABC):
6-
@abstractmethod
7-
def connect(self) -> None:
8-
pass
9-
106
@abstractmethod
117
def close(self) -> None:
128
pass
@@ -58,7 +54,7 @@ def __init__(self, database_object:Database) -> None:
5854
- database_object (Database): Database connection object to create the cursor.
5955
"""
6056
self.database = database_object
61-
self.__cursor = self.database.__conn.cursor()
57+
self.__cursor = self.database.conn.cursor()
6258

6359
@property
6460
def cursor(self) -> object:

projects/DatabaseConnectionWithOOP/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222

2323
# Fetching data from database in users table
2424
result = my_cursor.execute_simple_select_query('users', users_fields)
25-
print(result)
25+
result2 = my_cursor.execute_simple_select_query('users', ['username', 'age'])
26+
print('First fetch:', result)
27+
print('Second fetch:', result2)

0 commit comments

Comments
 (0)