-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add common file for each course
- Loading branch information
Showing
9 changed files
with
52 additions
and
184 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 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
40 changes: 0 additions & 40 deletions
40
src/courses/essential-sql/2.2-select-multiple-columns/files/main.py
This file was deleted.
Oops, something went wrong.
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
40 changes: 0 additions & 40 deletions
40
src/courses/essential-sql/2.3-renaming-columns-with-as/files/main.py
This file was deleted.
Oops, something went wrong.
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
40 changes: 0 additions & 40 deletions
40
src/courses/essential-sql/2.4-renaming-columns-without-as/files/main.py
This file was deleted.
Oops, something went wrong.
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
78 changes: 39 additions & 39 deletions
78
.../2.1-select-a-single-column/files/main.py → ...courses/essential-sql/files/setup_data.py
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 |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import sqlite3 | ||
import os | ||
from faker import Faker | ||
from prettytable import from_db_cursor, MARKDOWN | ||
from enum import Enum | ||
|
||
def setup(connection): | ||
fake = Faker() | ||
Faker.seed(0) | ||
|
||
cur = connection.cursor() | ||
|
||
cur.execute("CREATE TABLE customers(first_name, last_name, age, gender)") | ||
|
||
class Gender(Enum): | ||
M = "M" | ||
F = "F" | ||
|
||
for i in range(10): | ||
cur.execute( | ||
"INSERT INTO customers (first_name, last_name, age, gender) VALUES (?, ?, ?, ?)", | ||
( | ||
fake.first_name(), | ||
fake.last_name(), | ||
fake.pyint(max_value=80) + 20, | ||
fake.enum(Gender).value) | ||
) | ||
|
||
if __name__ == "__main__": | ||
|
||
con = sqlite3.connect("tutorial.db") | ||
cur = con.cursor() | ||
setup(connection=con) | ||
query = open('query.sql', 'r').read() | ||
try: | ||
res = cur.execute(query) | ||
table = from_db_cursor(cur) | ||
print(table) | ||
except Exception as e: | ||
import sqlite3 | ||
import os | ||
from faker import Faker | ||
from prettytable import from_db_cursor, MARKDOWN | ||
from enum import Enum | ||
|
||
def setup(connection): | ||
fake = Faker() | ||
Faker.seed(0) | ||
|
||
cur = connection.cursor() | ||
|
||
cur.execute("CREATE TABLE customers(first_name, last_name, age, gender)") | ||
|
||
class Gender(Enum): | ||
M = "M" | ||
F = "F" | ||
|
||
for i in range(10): | ||
cur.execute( | ||
"INSERT INTO customers (first_name, last_name, age, gender) VALUES (?, ?, ?, ?)", | ||
( | ||
fake.first_name(), | ||
fake.last_name(), | ||
fake.pyint(max_value=80) + 20, | ||
fake.enum(Gender).value) | ||
) | ||
|
||
if __name__ == "__main__": | ||
|
||
con = sqlite3.connect("tutorial.db") | ||
cur = con.cursor() | ||
setup(connection=con) | ||
query = open('query.sql', 'r').read() | ||
try: | ||
res = cur.execute(query) | ||
table = from_db_cursor(cur) | ||
print(table) | ||
except Exception as e: | ||
print("Error:", str(e)) |