This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export ZSH="$HOME/.oh-my-zsh" | |
| ZSH_THEME="robbyrussell" | |
| # plugins | |
| plugins=( | |
| git | |
| macos | |
| vscode | |
| zsh-autosuggestions | |
| zsh-safe-rm |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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() |