Last active
February 13, 2020 13:06
-
-
Save florestankorp/771efe452d51eda0401042f2a2c5dd15 to your computer and use it in GitHub Desktop.
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
import sqlite3 | |
import sys | |
def main(): | |
if len(sys.argv) < 2: | |
print("I") | |
return | |
HOUSE = sys.argv[1] | |
connection = sqlite3.connect('students.db') | |
cursor = connection.cursor() | |
cursor.execute(""" | |
--sql | |
SELECT * FROM students WHERE house=:house | |
--endsql | |
""", {'house': HOUSE}) | |
results = cursor.fetchall() | |
for result in results: | |
first = result[0] | |
middle = result[1] | |
last = result[2] | |
birth = result[4] | |
print( | |
first, | |
middle if middle else '', | |
last, | |
birth | |
) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment