Skip to content

Commit

Permalink
Final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gabll committed Apr 24, 2015
0 parents commit 147941c
Show file tree
Hide file tree
Showing 43 changed files with 6,740 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Credentials files #
#####################
credentials.py

# IPython notebook checkpoints #
################################
/.ipynb_checkpoints/*.*

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
674 changes: 674 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions MySQLconnection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import credentials
import pymysql

class MySQLconnection:

def __init__(self, host, user, pwd, db):
self.db = pymysql.connect(host=host, user=user, passwd=pwd, db=db)
self.cursor = self.db.cursor()

def execute_query(self, query_string):
""" Execute query and return cursor """
self.cursor.execute(query_string)
return self.cursor

def get_field_value(self, field, table, key_field, key_id):
""" Return a field from a table given the primary key value """
self.cursor.execute("""
SELECT """ + str(field) + """
FROM """ + str(table) + """
WHERE """ + str(key_field) + """ = """ + str(key_id) + """
""")
result = self.cursor.fetchall()[0][0]
return result

def close(self):
""" Close active connection """
self.cursor.close()
self.db.close()

if __name__ == "__main__":
conn = MySQLconnection(credentials.mysql_host,
credentials.mysql_user,
credentials.mysql_pwd,
credentials.mysql_db)
print conn.get_field_value('rest_name', 'restaurants', 'rest_id', 220)
conn.close()
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Metis-Kojak
Recommendation engine on restaurant reviews
(week 9-12)

[Webapp](http://restommendation.com) - [Blog post](http://gabll.github.io/blog/2015/04/07/recommendation-restaurants/)

*Note: The code in this repository is only an example that differs from the actual code used in the webapp and it's not intended for being replicated "as is".*


GNU General Public License v3.0
Loading

0 comments on commit 147941c

Please sign in to comment.