Hack with Data
  • Welcome to Hack with Data
  • Overview
    • โœจCourse Overview
  • Data Intro
    • ๐Ÿ—„๏ธImportance of Data in Today's World
    • ๐ŸขWhere Data Lives
    • ๐Ÿ”นWays to Logically Store Data
    • ๐Ÿ”Security Measures for Protecting Data
    • ๐ŸงนData Cleaning and Preprocessing
  • WORKING WITH DATA
    • โ‰๏ธQuerying Databases with SQL
    • ๐Ÿ“ฑExample of Querying Data from Python
    • ๐Ÿ”Introduction to APIs
  • DATA ANALYSIS AND VISUALIZATION
    • ๐Ÿ”ขIntroduction to Data Analysis
    • ๐Ÿ“ŠData Visualization Tools (Excel, Tableau, PowerBI)
    • ๐ŸŒณVisualization and Data for Environmental Initiatives
  • REAL-WORLD APPLICATIONS
    • ๐Ÿ”Data in Cybersecurity
    • ๐Ÿง‘โ€๐Ÿ’ปCareer Paths in Data
  • CONCLUSION
    • ๐ŸฅณCourse Recap
    • ๐Ÿ“Quiz
    • ๐Ÿ“„Keep on Learning
  • SouthHills Info Request
Powered by GitBook
On this page
  1. WORKING WITH DATA

Example of Querying Data from Python

PreviousQuerying Databases with SQLNextIntroduction to APIs

Last updated 1 year ago

import sqlite3

con = sqlite3.connect('thenameofyoursqlitedatabase.db')

cursor = con.cursor()

resultset = cursor.execute("SELECT * FROM yourtablename")

for row in resultset:
  print(row)

You can see the SQL code embedded in the Python code above. Essentially, the Python code is making a connection to the database and running the SQL code that the programmer specified.

If you want to play with this example on your own, feel free to fork and run this code sample at:

๐Ÿ“ฑ
https://replit.com/@gsantella/sqlite#main.py