Skip to content

Instantly share code, notes, and snippets.

@florestankorp
Last active February 13, 2020 13:06
Show Gist options
  • Save florestankorp/771efe452d51eda0401042f2a2c5dd15 to your computer and use it in GitHub Desktop.
Save florestankorp/771efe452d51eda0401042f2a2c5dd15 to your computer and use it in GitHub Desktop.
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