Skip to content

Instantly share code, notes, and snippets.

@BexTuychiev
Last active July 21, 2020 16:59
Show Gist options
  • Save BexTuychiev/6a11d4f269b47081ace42b038f3ee9cf to your computer and use it in GitHub Desktop.
Save BexTuychiev/6a11d4f269b47081ace42b038f3ee9cf to your computer and use it in GitHub Desktop.
import pandas as pd
# Create a cursor object
cursor = connection.cursor()
# Execute any SQL query
results = cursor.execute("""
SELECT table1.column1, table2.column2
FROM table1
JOIN table2 ON table1.primary = table2.foreign
ORDER BY 2
""")
# Load into a DataFrame
df = pd.DataFrame(results.fetchall())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment