Skip to content

Instantly share code, notes, and snippets.

View corralm's full-sized avatar

Miguel Corral Jr. corralm

View GitHub Profile
@corralm
corralm / .zshrc
Created November 2, 2022 23:01
.zshrc settings
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
# plugins
plugins=(
git
macos
vscode
zsh-autosuggestions
zsh-safe-rm
@corralm
corralm / sql_practice.ipynb
Last active April 25, 2026 05:25
[Medium] SQL Queries on Employee db
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corralm
corralm / top_10_salaries.py
Created July 5, 2020 19:53
[Medium] Top 10 Salaries
# single-line query
%sql SELECT salary FROM salaries ORDER BY salary DESC LIMIT 10
# multi-line query (use double %%)
%%sql
SELECT salary
FROM salaries
ORDER BY salary DESC
LIMIT 10
@corralm
corralm / tips.py
Created July 5, 2020 19:53
[Medium] ipython-sql Tips
# limits displayed results; entire set is still pulled into memory
%config SqlMagic.displaylimit=<int>
# limits the result set (good for large sets that can slow down your browser)
%config SqlMagic.autolimit=<int>
# return Pandas DataFrames instead of regular result sets
%config SqlMagic.autopandas=True
@corralm
corralm / sqlalchemy.csv
Created July 5, 2020 19:52
[Medium] SQLAlchemy
Dialect Driver Conda Install Driver
MySQL PyMySQL conda install -c anaconda pymysql
PostgreSQL Pyscopg2 conda install -c conda-forge psycopg2
SQLite Pysqlite conda install -c prometeia pysqlite
Oracle Cx Oracle conda install -c anaconda cx_oracle
Microsoft SQL Server Pyodbc conda install -c conda-forge pyodbc
@corralm
corralm / sql_pandas.py
Created July 5, 2020 19:52
[Medium] SQL Pandas
# assign to variable (single-line)
top_10_salaries = %sql SELECT salary FROM salaries ORDER BY salary DESC LIMIT 10
# assign to variable (multi-line)
%%sql top_10_salaries <<
SELECT salary
FROM salaries
ORDER BY salary DESC
LIMIT 10
@corralm
corralm / sql_connection.py
Last active July 5, 2020 19:55
[Medium] SQLAlchemy MySQL Connection
# load the ipython-sql extension
%load_ext sql
# Option1: Show credentials
%sql mysql+pymysql://user:pass@localhost:3306/employees
# Option2: Hide password using getpass
import getpass
user = 'miguel'
password = getpass.getpass()