Skip to content

Commit 9de02e8

Browse files
committed
Refactored drop_table method to drop
1 parent 100c931 commit 9de02e8

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ The entire MySQL-toolkit module can be utilized through a single import.
2424
from mysql.toolkit import MySQL
2525
```
2626

27+
The MySQL class's methods are broken down into three categories and inherited via sub-modules.
28+
29+
**core**
30+
31+
* select
32+
* select_all
33+
* select_all_join (coming soon)
34+
* select_where
35+
* insert
36+
* insert_many
37+
* update
38+
* truncate
39+
* drop
40+
2741
## Built With
2842

2943
* [differentiate](https://github.com/mrstephenneal/differentiate) - Compare multiple data sets and retrieve the unique, non-repeated elements.

mysql/toolkit/components/advanced.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def drop_empty_tables(self):
9292
for table, count in counts.items():
9393
if count < 1:
9494
# Drop table if it contains no rows
95-
self.drop_table(table)
95+
self.drop(table)
9696
self._printer('Dropped table', table)
9797
drops.append(table)
9898
return drops

mysql/toolkit/components/core.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ def select(self, table, cols, _print=True):
1212
statement = "SELECT " + cols_str + " FROM " + wrap(table)
1313
return self._fetch(statement, _print)
1414

15+
def select_all(self, table):
16+
"""Query all rows and columns from a table."""
17+
# Concatenate statement
18+
statement = "SELECT * FROM " + wrap(table)
19+
return self._fetch(statement)
20+
21+
def select_all_join(self, table1, table2, key):
22+
"""Left join all rows and columns from two tables where a common value is shared."""
23+
# TODO: Write function to run a select * left join query
24+
pass
25+
1526
def select_where(self, table, cols, where):
1627
"""Query certain columns from a table where a particular value is found."""
1728
# Either join list of columns into string or set columns to * (all)
@@ -26,17 +37,6 @@ def select_where(self, table, cols, where):
2637
statement = ("SELECT " + cols_str + " FROM " + wrap(table) + ' WHERE ' + str(where_col) + '=' + str(where_val))
2738
self._fetch(statement)
2839

29-
def select_all(self, table):
30-
"""Query all rows and columns from a table."""
31-
# Concatenate statement
32-
statement = "SELECT * FROM " + wrap(table)
33-
return self._fetch(statement)
34-
35-
def select_all_join(self, table1, table2, key):
36-
"""Left join all rows and columns from two tables where a common value is shared."""
37-
# TODO: Write function to run a select * left join query
38-
pass
39-
4040
def insert(self, table, columns, values):
4141
"""Insert a singular row into a table"""
4242
# Concatenate statement
@@ -96,4 +96,4 @@ def truncate(self, table):
9696
def drop_table(self, table):
9797
"""Drop a table from a database."""
9898
self.execute('DROP TABLE ' + wrap(table))
99-
return table
99+
return table

0 commit comments

Comments
 (0)