Skip to content

Instantly share code, notes, and snippets.

@qiuwch
Created June 10, 2015 00:17
Show Gist options
  • Select an option

  • Save qiuwch/8ca02561d86de23f5310 to your computer and use it in GitHub Desktop.

Select an option

Save qiuwch/8ca02561d86de23f5310 to your computer and use it in GitHub Desktop.
Python script for connecting to database
%pylab inline
import pandas as pd
import sqlite3
con = sqlite3.connect("../Project_202a/yelp.db")
df = pd.read_sql(“select * from xx", con)
import MySQLdb
import pandas as pd
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="", # your password
db="iiq") # name of the data base
pd.read_sql("SELECT * FROM levels", db)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment