-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 147941c
Showing
43 changed files
with
6,740 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
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() |
This file contains 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
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 |
Oops, something went wrong.