Skip to content

Instantly share code, notes, and snippets.

@vb100
Created June 18, 2018 21:47
Show Gist options
  • Save vb100/63a8c83c8c02f8433eb592e28c7bbb3e to your computer and use it in GitHub Desktop.
Save vb100/63a8c83c8c02f8433eb592e28c7bbb3e to your computer and use it in GitHub Desktop.
Selecting data from a Table: raw SQL
# Build select statement for census table: stmt
stmt = 'SELECT * FROM census'
# Execute the statement and fetch the results: results
results = connection.execute(stmt).fetchall()
# Print Results
print(results)
@vb100
Copy link
Author

vb100 commented Jun 18, 2018

[('Illinois', 'M', 0, 89600, 95012), ('Illinois', 'M', 1, 88445, 91829), ('Illinois', 'M', 2, 88729, 89547), ('Illinois', 'M', 3, 88868, 90037), ('Illinois', 'M', 4, 91947, 91111), ('Illinois', 'M', 5, 93894, 89802), ('Illinois', 'M', 6, 93676, 88931), ('Illinois', 'M', 7, 94818, 90940), ('Illinois', 'M', 8, 95035, 86943), ('Illinois', 'M', 9, 96436, 86055), ('Illinois', 'M', 10, 97280, 86565), ('Illinois', 'M', 11, 94029, 86606), ('Illinois', 'M', 12, 92402, 89596), ('Illinois', 'M', 13, 89926, 91661), ('Illinois', 'M', 14, 90717, 91256), ('Illinois', 'M', 15, 92178, 92729), ('Illinois', 'M', 16, 90587, 93083), ('Illinois', 'M', 17, 92782, 94541), ('Illinois', 'M', 18, 90997, 100253), ('Illinois', 'M', 19, 89629, 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment