def __init__(self):
     self.__mysql = MySQL()
     WBSV_AYD1.app.config['MYSQL_DATABASE_USER'] = '******'
     WBSV_AYD1.app.config['MYSQL_DATABASE_PASSWORD'] = '******'
     WBSV_AYD1.app.config['MYSQL_DATABASE_DB'] = 'proyectoClase'
     WBSV_AYD1.app.config['MYSQL_DATABASE_HOST'] = 'localhost'
     self.__mysql.init_app(WBSV_AYD1.app)
Пример #2
0
    def __init__(self):
        self.app = Flask(__name__)
        self.mysql = MySQL()

        # mysql config
        self.app.config['MYSQL_DATABASE_USER'] = "******"
        self.app.config['MYSQL_DATABASE_PASSWORD'] = ""
        self.app.config['MYSQL_DATABASE_DB'] = "mastertestv2"
        self.app.config['MYSQL_DATABASE_HOST'] = "localhost"
        self.mysql.init_app(self.app)
Пример #3
0
def create_connection():
	mysql = MySQL()
	app = Flask(__name__)
	app.config['MYSQL_DATABASE_USER'] = '******'
	app.config['MYSQL_DATABASE_PASSWORD'] = ''
	app.config['MYSQL_DATABASE_DB'] = 'virball'
	app.config['MYSQL_DATABASE_HOST'] = 'localhost'
	mysql.init_app(app)
	con = mysql.connect()
	return con
Пример #4
0
def setupDb():
	mysql = MySQL()
	 
	# MySQL configurations
	app.config['MYSQL_DATABASE_USER'] = '******'
	app.config['MYSQL_DATABASE_PASSWORD'] = '******'
	app.config['MYSQL_DATABASE_DB'] = 'devathon'
	app.config['MYSQL_DATABASE_HOST'] = 'localhost'
	mysql.init_app(app)
	return mysql
Пример #5
0
def set_connection(app):
    mysql = MySQL()
    # MySQL configurations
    with open("project/credentials.txt", "r") as credentials_file:
        credentials = credentials_file.read().splitlines()

        app.config['MYSQL_DATABASE_USER'] = credentials[0]
        app.config['MYSQL_DATABASE_PASSWORD'] = credentials[1]
        app.config['MYSQL_DATABASE_DB'] = credentials[2]
        app.config['MYSQL_DATABASE_HOST'] = credentials[3]

        mysql.init_app(app)
        global conn
        conn = mysql.connect()
Пример #6
0
    def test_search(self):
        _startdate = '2017-03-23'
        _starttime = '01:00 PM'
        _type = 'G'
        mysql = MySQL()
        # MySQL configurations
        app.config['MYSQL_DATABASE_USER'] = '******'
        app.config['MYSQL_DATABASE_PASSWORD'] = '******'
        app.config['MYSQL_DATABASE_DB'] = 'lrrs'
        app.config['MYSQL_DATABASE_HOST'] = 'localhost'
        mysql.init_app(app)

        conn = mysql.connect()
        cursor = conn.cursor()
        cursor.callproc('sp_searchrooms', args=(_type, _starttime, _startdate))
        assert cursor.rowcount == 1
Пример #7
0
class Repository:
    instance = None

    @classmethod
    def getInstance(cls,
                    db_user='******',
                    db_password='******',
                    db_database='accountbook'):
        if cls.instance is None:
            cls.instance = cls(db_user, db_password, db_database)
        return cls.instance

    def __init__(self, db_user, db_password, db_database):
        self.db_user = db_user
        self.db_password = db_password
        self.db_database = db_database
        self.db_source = MySQL()

    def selectQuery(self, query, args, **kwargs):
        conn = self.db_source.connect()
        cursor = conn.cursor()
        cursor.execute(query, args)
        results = []
        #columns 컬럼명을 리스트로 생성
        columns = [d[0] for d in cursor.description]
        # 결과 키 값 쌍을 results에 추가
        if ('header' in kwargs):
            results.append(dict(zip(columns, columns)))
        for row in cursor:
            results.append(dict(zip(columns, row)))
        cursor.close()
        conn.close()
        return results

    def executeQuery(self, query, args):
        conn = self.db_source.connect()
        cursor = conn.cursor()
        cursor.execute(query, args)
        conn.commit()
        cursor.close()
        conn.close()
        return 'success'

    def findOne(self, obj):
        return self.selectQuery(
            QueryBuilder().select(obj.select()).table(
                type(obj).__name__).where(obj.filter()).build(), ())
Пример #8
0
def connect():
    """connect user to DataBase on host"""
    host = "psotty.mysql.pythonanywhere-services.com"
    user = "******"
    pswd = ""
    database = "psotty$fitness"

    mysql = MySQL()

    # MySQL configurations
    app.config['MYSQL_DATABASE_USER'] = user
    app.config['MYSQL_DATABASE_PASSWORD'] = pswd
    app.config['MYSQL_DATABASE_DB'] = database
    app.config['MYSQL_DATABASE_HOST'] = host
    mysql.init_app(app)
    db = mysql.connect()

    return db
Пример #9
0
class MySqlConfig:
    mysql = MySQL()

    def initDatabase(app):
        # MySQL configurations
        app.config['MYSQL_DATABASE_USER'] = '******'
        app.config['MYSQL_DATABASE_PASSWORD'] = '******'
        app.config['MYSQL_DATABASE_DB'] = 'adwisedb'
        app.config['MYSQL_DATABASE_HOST'] = 'localhost'

        MySqlConfig.mysql.init_app(app)
Пример #10
0
    def setConfig(cls, app):
        mysql = MySQL()

        app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0

        app.config['MYSQL_DATABASE_USER'] = AccountBookRepository.getInstance(
        ).db_user
        app.config[
            'MYSQL_DATABASE_PASSWORD'] = AccountBookRepository.getInstance(
            ).db_password
        app.config['MYSQL_DATABASE_DB'] = AccountBookRepository.getInstance(
        ).db_database

        mysql.init_app(app)
        AccountBookRepository.getInstance().db_source = mysql

        #custom rule
        app.custom_id_min_length = 6
        app.custom_password_min_length = 6

        return app
Пример #11
0
from flask import Flask, render_template, request
import pymongo as mongo
import sys
from flask.ext.mysql import MySQL
mongo_client = mongo.MongoClient(
    "mongodb://*****:*****@mongocluster-shard-00-00-5qypc.mongodb.net:27017,"
    "mongocluster-shard-00-01-5qypc.mongodb.net:27017,"
    "mongocluster-shard-00-02-5qypc.mongodb.net:27017/test?ssl=true&replicaSet=mongocluster-shard-0&authSource=admin"
)
actors_db = mongo_client.actors

app = Flask(__name__)

mysql = MySQL()
# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'news'
app.config[
    'MYSQL_DATABASE_HOST'] = 'mydbfeedmenews.cffkuryafwgu.us-east-1.rds.amazonaws.com'
mysql.init_app(app)
cursor = mysql.connect().cursor()

male_actors = actors_db.male
female_actors = actors_db.female


@app.route('/')
def index():
    return render_template('index.html')
Пример #12
0
from flask import Flask, url_for, request, jsonify, make_response, g
from flask.ext.mysql import MySQL
from import_config import load_config
import json
import types

config = load_config()

mysql = MySQL()
basic_api = Flask(__name__)

basic_api.config['MYSQL_DATABASE_USER'] = config["database"]["user_name"]
basic_api.config['MYSQL_DATABASE_PASSWORD'] = config["database"]["password"]
basic_api.config['MYSQL_DATABASE_DB'] = config["database"]["db_instance"]
basic_api.config['MYSQL_DATABASE_HOST'] = config["database"]["connection_url"]

mysql.init_app(basic_api)

url_root = '/todo/api/v3.0/'

def format_json(element):
	new_task = {}
	new_task["id"] = element[0]
	new_task["title"] = element[1]
	new_task["description"] = element[2]
	new_task["done"] = element[3]
	return new_task

@basic_api.before_request
def db_connect():
	g.db_conn = mysql.connect()
Пример #13
0
from flask import Flask, render_template, redirect, url_for, request, session, flash, g, jsonify
from flask.ext.mysql import MySQL
from flask_restful import Resource, Api, reqparse
from functools import wraps
from werkzeug.contrib.fixers import ProxyFix
import sqlite3
import MySQLdb
import tweepy, requests, json
from facepy import GraphAPI

application = Flask(__name__)
application.secret_key = 'alldefdigital'
application.wsgi_app = ProxyFix(application.wsgi_app)
api = Api(application)

mysql = MySQL()
application.config['MYSQL_DATABASE_USER'] = '******'
application.config['MYSQL_DATABASE_PASSWORD'] = '******'
application.config['MYSQL_DATABASE_DB'] = 'DB1'
application.config[
    'MYSQL_DATABASE_HOST'] = 'creatorsapplicants-08282016.cuhrgyuzad7j.us-west-2.rds.amazonaws.com'

mysql.init_app(application)

consumer_key = 'aYJWS2nOeqMavQAPabi3ULWtz'
consumer_secret = 'YxM7MhfBV45G105gj7v7W9oqMlzHldHAqwzz6oq5Oqp1n6Sj5q'
access_token = '2174711515-GiTm6zgUp7YjNWAEGbN1B60j6ymDgaebC5eaOHk'
access_token_secret = '1DWFca5iU1l0ig3LOk9x3U2cJ3dMOdFIaNRUmx1o166UF'


def login_required(f):
Пример #14
0
from flask import Flask, g
from flask.ext import restful
from flask import request
from app.api import outApi, user, common
from flask.ext.mysql import MySQL
from flask_cors import *
# from flask import make_response
import traceback
import json
mysql = MySQL()
app = Flask(__name__)
CORS(app, supports_credentials=True)
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'secondhand'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
conn = mysql.connect()
api = restful.Api(app)


@app.before_request
def my_before_request():
    g.db = conn


    # print('before request', request.headers)
@app.after_request
def my_after_request(self):
    try:
        print('after request')
Пример #15
0
from __future__ import division
from flask import Flask, Response, request, abort, render_template, jsonify
from flask.ext.mysql import MySQL
from flask.ext.cors import CORS
import json
import time
import datetime
import math
import os
import requests

application = Flask(__name__)
CORS(application)
mysql = MySQL()
 
application.config['MYSQL_DATABASE_USER'] = os.environ.get('RDS_USERNAME')
application.config['MYSQL_DATABASE_PASSWORD'] = os.environ.get('RDS_PASSWORD')
application.config['MYSQL_DATABASE_DB'] = 'parking'
application.config['MYSQL_DATABASE_HOST'] = 'parking.c9q5edmigsud.us-west-2.rds.amazonaws.com'
application.config['MYSQL_DATABASE_PORT'] = 3306
mysql.init_app(application)

@application.route('/')    
def index():
    return render_template('index.html')

@application.route('/paystations', methods=['GET', 'POST'])
def get_paystations():
    element_keys = request.args.get('element_keys', None)
    cur = mysql.connect().cursor()
    query = "SELECT * FROM blockfaces"
Пример #16
0
class Database(object):

    def __init__(self, app):
        self.mysql = MySQL()
        self.mysql.init_app(app)

    ####### USERS #######

    def get_all_users(self):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT uid, uname, email, pass FROM Users WHERE is_active = True"""
        cursor.execute(query)
        rows = cursor.fetchall()
        cursor.close()
        users = []
        for row in rows:
            users.append(User(row[0], row[1], row[2], row[3]))
        return users

    def get_user(self, username=None, email=None, password=None, dob=None):
        if email is None and username is None:
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        first = True
        query = """SELECT uid, uname, email, pass, udob FROM Users WHERE """
        if username:
            query += """uname = '%s'""" % (username)
            first = False
        if email:
            if not first:
                query += """ AND """
            query += """email = '%s'""" % (email)
            first = False
        if password:
            if not first:
                query += """ AND """
            query += """pass = '******'""" % (password)
        if dob:
            if not first:
                query += """ AND """
            query += """udob = '%s'""" % (dob)
        cursor.execute(query)
        u = cursor.fetchone()
        cursor.close()
        if not u:
            return None
        return User(u[1], u[2], u[3], u[4], u[0])

    def insert_user(self, username, email, password, dob):
        if (not (username and email and password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """INSERT INTO Users (uname, email, pass, udob) VALUES ('%s', '%s', '%s', '%s')""" % (username, email, password, dob)
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        return User(username, email, password, dob)

    def update_user(self, username, email=None, password=None, is_active=True):
        if (not (username) or not (email or password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """UPDATE Users SET is_active = %s""" % (str(is_active))
        if email:
            statement += """, email = '%s'""" % email
        if password:
            statement += """, pass = '******'""" % password
        statement += """WHERE uname = '%s'""" % unsername
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        return User(username, email, password)

    ####### MOVIES #######

    def get_people_like(self, pname, limit=10):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT pid, pname FROM People WHERE pname LIKE '%s%%' OR pname LIKE '%%%s' OR pname LIKE '%%%s%%' LIMIT %s;""" % (pname, pname, pname, limit)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        r = []
        for result in results:
            r.append(dict(id=result[0],name=result[1]))
        return json.dumps(r)

    def get_movies_like(self, title, limit=5):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT mid, title FROM Movies WHERE title LIKE '%s%%' OR title LIKE '%%%s' OR title LIKE '%%%s%%' LIMIT %s;""" % (title, title, title, limit)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        r = []
        for result in results:
            r.append(dict(id=result[0],name=result[1]))
        return json.dumps(r)

    def get_genres_like(self, gname, limit=5):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT gid, gname FROM Genres WHERE gname LIKE '%s%%' OR gname LIKE '%%%s' OR gname LIKE '%%%s%%' LIMIT %s;""" % (gname, gname, gname, limit)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        r = []
        for result in results:
            r.append(dict(id=result[0],name=result[1]))
        return json.dumps(r)

    def get_movie_by_id(self, mid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "mid,title,mdate,runtime,languages,description,budget,box_office,country"
        query = """SELECT %s FROM Movies WHERE mid='%s';""" % (cols, mid)
        cursor.execute(query)
        movie = list(cursor.fetchone())
        cursor.close()
        r = {}
        lcols = cols.split(",")
        movie[2] = movie[2].year
        for (num,val) in enumerate(movie):
            r[lcols[num]] = val
        return Movie(*r)

    def get_movie_by_id(self, mid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "mid,title,mdate,runtime,languages,description,budget,box_office,country"
        #mids = ','.join(["'%s'" % (val) for val in mid])
        query = """SELECT %s FROM Movies WHERE mid='%s';""" % (cols, mid)
        cursor.execute(query)
        results = cursor.fetchone()
        cursor.close()
        if not results:
            return None
        movie = list(results)
        if movie[2]:
            movie[2] = movie[2].year
        return Movie(*movie)

    def get_people_from_movie(self, mid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "People.pid,pname,pdob"
        lcols = cols.split(",")
        query = """SELECT %s FROM Involved_In INNER JOIN People ON People.pid=Involved_In.pid WHERE mid='%s'""" % (cols, mid)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        results = [list(result) for result in results]
        people = []
        for person in results:
            if person[2]:
                person[2] = person[2].year
            else:
                person[2] = '0000'
            people.append(Person(*person))
        return people

    def get_all_credits_by_person(self, pid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "Movies.mid,Movies.title,directed,produced,wrote,composed,acted"
        lcols = cols.split(",")
        query = """SELECT %s FROM Involved_In INNER JOIN Movies ON Involved_In.mid=Movies.mid WHERE pid='%s'""" % (cols, pid)
        cursor.execute(query)
        results = list(cursor.fetchall())
        cursor.close()
        credits = []
        for credit in results:
            c = {}
            for (num,val) in enumerate(credit):
                c[lcols[num]] = val
                credits.append(c)
        return json.dumps(credits)

    def get_movie_credits_by_person(self, mid, pid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "pid,mid,directed,produced,wrote,composed,acted"
        lcols = cols.split(",")
        query = """SELECT %s FROM Involved_In WHERE pid='%s' AND mid='%s'""" % (cols, pid, mid)
        cursor.execute(query)
        results = list(cursor.fetchone())
        cursor.close()
        credit = Credit(*results)
        return credit

    def get_genre(self, mid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "gid,gname"
        query = """SELECT %s FROM Genres WHERE gid IN (SELECT gid FROM Is_Genre WHERE mid='%s');""" % (cols,mid)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        results = [list(result) for result in results]
        genres = [Genre(*x) for x in results]
        return genres

    def get_movies_by_genre(self, gid, limit=20):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT mid FROM Is_Genre WHERE gid=%s ORDER BY RAND() LIMIT %s;""" % (gid, limit)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        results = [result[0] for result in results]
        return results #mids

    def get_genre_name(self, gid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT gname FROM Genres WHERE gid=%s;""" % (gid)
        cursor.execute(query)
        results = cursor.fetchone()
        cursor.close()
        if not results:
            return None
        result = results[0]
        return result

    def get_person_name(self, pid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT pname FROM People WHERE pid=%s;""" % (pid)
        cursor.execute(query)
        results = cursor.fetchone()
        cursor.close()
        if not results:
            return None
        result = results[0]
        return result #pids

    def get_movies_by_person(self, pid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        cols = "Involved_In.mid,mdate,title,directed,produced,wrote,composed,acted"
        query = """SELECT %s FROM Involved_In JOIN Movies ON Involved_In.mid=Movies.mid WHERE pid=%s;""" % (cols,pid)
        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        lcols = cols.split(",")
        lcols[0] = "mid"
        if not results:
            return None
        results = [list(result) for result in results]
        for i in xrange(len(results)):
            if results[i][1]:
                results[i][1] = results[i][1].year
        movies = []
        for idx1,m in enumerate(results):
            tmp = {}
            for idx2,col in enumerate(lcols):
                tmp[col]=m[idx2]
            movies.append(DTmp(**tmp))
        return movies

    def rate(self, table, uid, pkey_name, oid, rating):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """INSERT INTO %s (uid,%s,urating) VALUES ('%s','%s','%s') ON DUPLICATE KEY UPDATE urating=VALUES(urating)""" % (table, pkey_name, uid, oid, rating)
        cursor.execute(query)
        results = cursor.fetchone()
        self.mysql.get_db().commit()
        cursor.close()
        if not results:
            return None
        results = list(results)
        return results

    def get_rating(self, table, uid, pkey_name, oid):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT urating FROM %s WHERE uid=%s AND %s='%s';""" % (table, uid, pkey_name, oid)
        cursor.execute(query)
        results = cursor.fetchone()
        cursor.close()
        if not results:
            return False, 0
        return True, results[0]

    def recommend(self, uid, limit=15):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """
            SELECT mid,title
            FROM Movies
            WHERE mid IN (
                SELECT DISTINCT(mid)
                FROM Movies
                WHERE mid IN (
                    SELECT mid
                    FROM Involved_In
                    WHERE pid IN (
                        SELECT pid
                        FROM Likes_Person
                        WHERE uid={0}
                        ORDER BY urating DESC
                    )
                )
                OR mid IN (
                    SELECT mid
                    FROM Involved_In
                    WHERE pid IN (
                        SELECT pid
                        FROM Involved_In
                        JOIN Has_Watched
                        ON Involved_In.mid=Has_Watched.mid
                        WHERE uid={0}
                        ORDER BY urating DESC
                    )
                )
            )
            AND mid NOT IN (
                SELECT mid
                FROM Has_Watched
                WHERE uid={0}
            )
            ORDER BY RAND()
            LIMIT {1};"""
        query = query.format(uid, limit)

        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        results = [DTmp(**{'mid': r[0], 'title': r[1]}) for r in results]
        return results

    def recommend_better(self, uid, limit=30):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """
            SELECT m.mid,m.title,i.pid,AVG(Likes_Person.urating) AS urt
            FROM Movies m
            JOIN Involved_In i
            ON m.mid=i.mid
            LEFT OUTER JOIN Likes_Person
            ON i.pid=Likes_Person.pid
            WHERE m.mid IN (
                SELECT DISTINCT(mm.mid)
                FROM Movies mm
                WHERE mm.mid IN (
                    SELECT ii.mid
                    FROM Involved_In ii
                    WHERE ii.pid IN (
                        SELECT lp.pid
                        FROM Likes_Person lp
                        WHERE uid={0}
                        ORDER BY lp.urating DESC
                    )
                )
                OR mm.mid IN (
                    SELECT iii.mid
                    FROM Involved_In iii
                    WHERE iii.pid IN (
                        SELECT iiii.pid
                        FROM Involved_In iiii
                        JOIN Has_Watched hhhh
                        ON iiii.mid=hhhh.mid
                        WHERE uid={0}
                        ORDER BY hhhh.urating DESC
                    )
                )
            )
            AND m.mid NOT IN (
                SELECT hw.mid
                FROM Has_Watched hw
                WHERE uid={0}
            )
            GROUP BY m.mid
            ORDER BY urt DESC
            LIMIT {1};"""
        query = query.format(uid, limit)

        cursor.execute(query)
        results = cursor.fetchall()
        cursor.close()
        results = [DTmp(**{'mid': r[0], 'title': r[1], 'score': r[3] if r[3] else float(0.0)}) for r in results]
        return results
Пример #17
0
from flask import Flask, render_template, flash, redirect, url_for, session, request, logging
from flask.ext.mysql import MySQL
import mysql.connector
import Smart_Shopper_Lib_Tester as SSL
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from passlib.hash import sha256_crypt
from functools import wraps

app = Flask(__name__)
#Config mysql
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'smartshopper'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'

mysql = MySQL(app)

cust_id = 2

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('home.html')


@app.route('/about')
def about():
    return render_template('aboutus.html')
Пример #18
0
class Database():
    def __init__(self, app):
        self.mysql = MySQL()
        self.mysql.init_app(app)

    def get_all_users(self):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT username, email, password FROM Users WHERE is_active = True"""
        cursor.execute(query)
        rows = cursor.fetchall()
        cursor.close()
        users = []
        for row in rows:
            users.append(User(row[0], row[1], row[2]))
        #self.mysql.get_db().close()
        return users

    def get_user(self, username=None, email=None, password=None):
        if email is None and username is None:
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        first = True
        query = """SELECT username, email, password, is_active FROM Users WHERE """
        if username:
            query += """username = '******'""" % (username)
            first = False
        if email:
            if not first:
                query += """ AND """
            query += """email = '%s'""" % (email)
            first = False
        if password:
            if not first:
                query += """ AND """
            query += """password = '******'""" % (password)
        cursor.execute(query)
        u = cursor.fetchone()
        cursor.close()
        #self.mysql.get_db().close()
        if not u:
            return None
        return User(u[0], u[1], u[2], u[3])

    def insert_user(self, username, email, password):
        if (not (username and email and password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """INSERT INTO Users (username, email, password) VALUES ('%s', '%s', '%s')""" % (
            username, email, password)
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        #self.mysql.get_db().close()
        return User(username, email, password)

    def update_user(self, username, email=None, password=None, is_active=True):
        if (not (username) or not (email or password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """UPDATE Users SET is_active = %s""" % (str(is_active))
        if email:
            statement += """, email = '%s'""" % email
        if password:
            statement += """, password = '******'""" % password
        statement += """ WHERE username = '******'""" % username
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        #self.mysql.get_db().close()
        return User(username, email, password)

    def get_all_players(self):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT player_id, first_name, last_name, nfl_team FROM Players"""
        cursor.execute(query)
        rows = cursor.fetchall()
        cursor.close()
        players = []
        for row in rows:
            players.append(Player(row[0], row[1], row[2], row[3]))
        #self.mysql.get_db().close()
        return players

    def get_player(self,
                   player_id=None,
                   first_name=None,
                   last_name=None,
                   nfl_team=None):
        if player_id is None and first_name is None and last_name is None and nfl_team is None:
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        first = True
        query = """SELECT player_id, first_name, last_name, nfl_team FROM Players WHERE """
        if player_id:
            query += """player_id = '%s'""" % (player_id)
            first = False
        if first_name:
            if not first:
                query += """ AND """
            query += """first_name = '%s'""" % (first_name)
            first = False
        if last_name:
            if not first:
                query += """ AND """
            query += """last_name = '%s'""" % (last_name)
            first = False
        if nfl_team:
            if not first:
                query += """ AND """
            query += """nfl_team = '%s'""" % (nfl_team)
            first = False
        cursor.execute(query)
        p = cursor.fetchone()
        cursor.close()
        #self.mysql.get_db().close()
        if not p:
            return None
        return Player(p[0], p[1], p[2], p[3])

    def insert_player(self, player_id, first_name, last_name, nfl_team):
        if (not (player_id and first_name and nfl_team)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """INSERT INTO Players (player_id, first_name, last_name, nfl_team) VALUES ('%s', '%s', '%s', '%s')""" % \
                        (player_id, first_name, last_name, nfl_team)
        try:
            cursor.execute(statement)
            self.mysql.get_db().commit()
            cursor.close()
            self.mysql.get_db().close()
        except Exception, e:
            print e
        return Player(player_id, first_name, last_name, nfl_team)
Пример #19
0
 def __init__(self, db_user, db_password, db_database):
     self.db_user = db_user
     self.db_password = db_password
     self.db_database = db_database
     self.db_source = MySQL()
Пример #20
0
import os
import uuid
import flask
import flask.views
from flask import render_template
from flask import request, make_response,send_from_directory
from werkzeug import secure_filename
from flask.ext.httpauth import HTTPBasicAuth
from flask import jsonify , json
app = flask.Flask(__name__,static_url_path='')
print app.static_url_path
from flask.ext.mysql import MySQL
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'forum'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
cursor = mysql.connect().cursor()
@app.route('/')
@app.route('/login',methods=['GET'])
def index():
    return render_template('login.html')

@app.route('/login', methods=['POST'])
def login():
    user = request.form['email']
    password = request.form['pass']
    return authenticate(user,password)

def authenticate(username, password):
Пример #21
0
from flask import Flask, render_template, request, jsonify
from flask.ext.socketio import SocketIO
from flask.ext.mysql import MySQL
from MySQLdb.cursors import DictCursor

import datetime
import numpy as np
import pandas as pd

from bokeh.plotting import figure
from bokeh.embed import components

app = Flask(__name__)
socketio = SocketIO(app)

mysql = MySQL(cursorclass = DictCursor)
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'iridium'
app.config['MYSQL_DATABASE_PORT'] = 3306
app.config['MYSQL_DATABASE_HOST'] = '127.0.0.1'

mysql.init_app(app)
conn = mysql.connect()
cursor = conn.cursor()

def insertData(in_rate,in_rate_avg,queue_len,queue_len_max,out_rate,ok_ratio,ok_rate,ok_ratio_total,ok_count_total,out_count,ok_rate_avg,drop_count_total,drop_count,ts):
    query = "INSERT INTO `iridium`.`iridium` (`id`, `in_rate`,`in_rate_avg`,`queue_len`,`queue_len_max`,`out_rate`,`ok_ratio`,`ok_rate`,`ok_ratio_total`,`ok_count_total`,`out_count`,`ok_rate_avg`,`drop_count_total`,`drop_count`,`ts`) VALUES (null,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,\"%s\");" % (in_rate,in_rate_avg,queue_len,queue_len_max,out_rate,ok_ratio,ok_rate,ok_ratio_total,ok_count_total,out_count,ok_rate_avg,drop_count_total,drop_count,ts)
    cursor.execute(query)
    conn.commit()
Пример #22
0
#
from __future__ import print_function
from flask import Flask
from flask import request, redirect, url_for, render_template, send_from_directory, session
from flask.ext.mysql import MySQL
from werkzeug import secure_filename
from mimetypes import MimeTypes
import os
import time
import logging
import boto3
from boto3.s3.transfer import S3Transfer
from config import *

image_uploader = Flask(__name__)
mysql = MySQL()
image_uploader.config['MYSQL_DATABASE_USER'] = DB_USER
image_uploader.config['MYSQL_DATABASE_PASSWORD'] = DB_PASS
image_uploader.config['MYSQL_DATABASE_DB'] = DB_NAME
image_uploader.config['MYSQL_DATABASE_HOST'] = DB_HOST
mysql.init_app(image_uploader)

#
# Help functions
#
def allowed(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in IMAGE_TYPES

def put_s3_objetct(image_name, storage_dir):
    mime = MimeTypes()
    s3 = boto3.client('s3', region_name=AWS_REGION)
Пример #23
0
# !/usr/bin/python
# -*- coding: utf-8 -*-

from config import config
from flask import Flask
from flask.ext.mysql import MySQL

__author__ = 'AidChow'

db = MySQL()


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    db.init_app(app)

    from .main import main as main_blueprint
    from .news import news as new_blueprint

    app.register_blueprint(main_blueprint)
    app.register_blueprint(new_blueprint, url_prefix='/news/api')
    return app
Пример #24
0
# from flask import Flask (Step 1)
# from flask import Flask, render_template # (Step 2)
# from flask import Flask, render_template, request # adding to enable view of posted values (Step 5)
from flask import Flask, render_template, json, request  # adding for json use
from flask.ext.mysql import MySQL  # adding for mySQL use (Step 7)
from werkzeug import generate_password_hash, check_password_hash

app = Flask(__name__)
mysql = MySQL()  # (Step 7)

# MySQL configurations (Step 7)
app.config['MYSQL_DATABASE_USER'] = '******'

app.config['MYSQL_DATABASE_PASSWORD'] = ''  # Update for testing

app.config['MYSQL_DATABASE_DB'] = 'BucketList'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)


@app.route("/")
def main():
    # return "Welcome!" (Step 1)
    return render_template('index.html')  # (Step 2)


@app.route('/showSignUp')  # adds signup page to routes (Step 3)
def showSignUp():
    return render_template('signup.html')

Пример #25
0
 def __init__(self, app):
     self.mysql = MySQL()
     self.mysql.init_app(app)
Пример #26
0
# pip install pdfkit
# pip3 install pdfkit
# Password encryption avoided for testing purposes

from flask import Flask, render_template, request, redirect, json, session
from flask.ext.mysql import MySQL
from flask.ext.uploads import UploadSet, IMAGES, configure_uploads
import MySQLdb, time, os, uuid, sys, json

__author__ = 'Robley < *****@*****.** >'

eureka = Flask(__name__)

eureka.secret_key = 'secret'

mysql = MySQL()

# Database configuration
eureka.config['MYSQL_DATABASE_USER'] = '******'
eureka.config['MYSQL_DATABASE_PASSWORD'] = '******'
eureka.config['MYSQL_DATABASE_DB'] = 'eureka'
eureka.config['MYSQL_DATABASE_HOST'] = 'localhost'
eureka.config['UPLOADED_PHOTOS_DEST'] = '../static/uplds'

mysql.init_app(eureka)


# Home page
@eureka.route('/')
def home_page():
    return render_template('index.html')
Пример #27
0
#!/bin/env python
from flask.ext.mysql import MySQL

mysql = MySQL()

app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'cs673'
app.config['MYSQL_DATABASE_HOST'] = '127.0.0.1'

conn = mysql.connect()
cursor = conn.cursor()

from app import create_app, socketio

app = create_app(debug=True)

if __name__ == '__main__':
    socketio.run(app)
Пример #28
0
from flask import Flask, request, Response, jsonify;
from flask_restful import Resource, Api, reqparse;
from flask.ext.mysql import MySQL;
import json;

app = Flask(__name__);

#MySQL configurations
app.config['MYSQL_DATABASE_USER']       ='******';
app.config['MYSQL_DATABASE_PASSWORD']   ='******';
app.config['MYSQL_DATABASE_DB']         ='analysis_app_db';
app.config['MYSQL_DATABASE_HOST']       ='localhost';

mysql=MySQL();
mysql.init_app(app);


class Tag(Resource):
    def get(self):
        try:
            query_result = execute_query("SELECT * FROM tb_tag");
            data = json.dumps(query_result);
            resp = Response(data, status=200, mimetype='application/json');
            return resp;

        except Exception as e:
            return {'error':str(e)};


class Test(Resource):
    def get(self):
Пример #29
0
from flask import Flask, render_template, json, request
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash

mysql = MySQL()
application = app = Flask(__name__)

# MySQL configurations
"""
application.config['MYSQL_DATABASE_USER'] = '******'
application.config['MYSQL_DATABASE_PASSWORD'] = '******'
application.config['MYSQL_DATABASE_DB'] = 'signup'
application.config['MYSQL_DATABASE_HOST'] = 'signup.cfj54gpjcmhy.us-west-2.rds.amazonaws.com:3306'
mysql.init_app(application)"""


@app.route('/')
def main():
    return render_template('index.html')

@app.route('/showSignUp')
def showSignUp():
    return render_template('signup.html')


@app.route('/signUp',methods=['POST','GET'])
def signUp():
    try:
        _name = request.form['inputName']
        _email = request.form['inputEmail']
        _password = request.form['inputPassword']
Пример #30
0
from flask import Flask,g,render_template,request,jsonify
import sqlite3
import database as db
from flask.ext.mysql import MySQL
from pymysql.cursors import DictCursor
import ln2sql,os


app = Flask(__name__)
mysql = MySQL(cursorclass=DictCursor)

# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'college'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
#app.config['MYSQL_DATABASE_PORT'] = 'localhost'
mysql.init_app(app)



@app.route('/')
@app.route('/getResults',methods=['GET','POST'])
def add_student():
	if request.method == 'GET':
		return render_template('index.html')
	else:
		query = request.form['query']
		print("gotcha",query)
		query = ln2sql.Ln2sql(database_path=os.path.join(os.getcwd(),'college.sql'),language_path=os.path.join(os.getcwd(),'english.csv')).get_query(query)  #get title of course with student whose name is Shravan
		status = db.run_query(query)
Пример #31
0
"""
The flask application package.
"""

from flask import Flask
from flask import render_template
from flask.ext.mysql import MySQL
from flask.ext.bootstrap import Bootstrap
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.mail import Mail, Message
from threading import Thread
from flask.ext.moment import Moment

mysql = MySQL()
login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.signin'
app = Flask(__name__)
bootstrap = Bootstrap(app)
app.secret_key = 'somtoskeyinwhichnobodycanguess'
app.config["MAIL_SERVER"] = "smtp.mail.yahoo.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = '******'
app.config["MAIL_PASSWORD"] = ''
app.config['DIALECT_APP_SUBJECT'] = '[Dialect App]'
app.config['DIALECT_APP_SENDER'] = '*****@*****.**'
#app.config['SECRET_KEY'] = 'my very secret yeeeys'
#app.config['MYSQL_DATABASE_USER'] = '******'
#app.config['MYSQL_DATABASE_PASSWORD'] = '******'
Пример #32
0
class Database(object):
    """Handles communication with the mysql database"""
    def __init__(self, app):
        self.mysql = MySQL()
        self.mysql.init_app(app)
        self.con = self.mysql.connect()
        self.cur = self.con.cursor()

    def GetCredit(self):
        """Get the total credits added

        Returns:
            Total credits added, in seconds
        """
        self.cur.execute('select sum(seconds) from credit;')
        rv = self.cur.fetchall()[0][0]
        return rv and int(rv) or 0

    def GetUsage(self):
        """Get the total internet usage according to the database

        Returns:
            Total usage in seconds
        """
        self.cur.execute('select sum(duration) from record;')
        rv = self.cur.fetchall()[0][0]
        return rv and int(rv) or 0

    def GetState(self):
        """Get the current internet state, and when that state was set

        A state change is written to the 'state' table when the Internet is
        enabled. It is removed when the Internet is disabled. So if there is
        a state record, we know that the Internet was enabled at some point.

        Returns:
            tuple:
                State (DISABLED or ENABLED)
                Time of last state change (0 if disabled)
        """
        self.cur.execute('select * from state;')
        rv = self.cur.fetchall()
        if not rv:
            return DISABLED, 0
        state, dt = rv[0]
        return state, dt

    def GetUsed(self):
        """Return the duration of internet that is used but not recorded yet

        Returns:
            Duration in seconds since the Internet was started
        """
        state, dt = self.GetState()
        if not state:
            return 0, 0
        return 1, math.floor((datetime.now() - dt).total_seconds())

    def RecordEnableTime(self):
        """Record that we have started a new internet session"""
        self.cur.execute('delete from state;')
        self.cur.execute(
            'insert into state (enabled, start) values (true, now());')
        self.con.commit()

    def RecordSession(self):
        """Record that the internet session has ended"""
        state, start = self.GetState()
        if state == DISABLED:
            # We did not write a record at the start of the session, so don't
            # know when it began
            print 'Missing record in "state" table'
            return
        cmd = (
            "insert into record (start, end, duration) values ('%s', now(), %d);"
            % (start.strftime('%Y-%m-%d %H:%M:%S'),
               (datetime.now() - start).total_seconds()))
        self.cur.execute(cmd)
        self.cur.execute('delete from state;')
        self.con.commit()

    def GetRemaining(self):
        """Get the remaining internet time in seconds

        This totals all credits, subtracts all usage and also subtracts any
        pending usage (the time since the Internet was started).

        Returns:
            Remaining time in seconds
        """
        credit = self.GetCredit()
        debit = self.GetUsage()
        db_state, used = self.GetUsed()
        return credit - debit - used
Пример #33
0
from flask import Flask, render_template, json, request
from flask.ext.mysql import MySQL

app = Flask(__name__)

mysql = MySQL()

app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'diradinsk'
app.config[
    'MYSQL_DATABASE_HOST'] = 'mysql://*****:*****@ada.sterncs.net:3306'
"""
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'lifehacks'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)"""

conn = mysql.connect()
cursor = conn.cursor()


@app.route("/")
def main():
    return render_template('home.html')


@app.route('/post.html')
def showSignUp():
    return render_template('post.html')
Пример #34
0
 def __init__(self, app):
     self.mysql = MySQL()
     self.mysql.init_app(app)
     self.con = self.mysql.connect()
     self.cur = self.con.cursor()
Пример #35
0
from flask import Flask
from flask.ext.mysql import MySQL

app = Flask(__name__)
app.debug = True

mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'tp_db'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'

mysql.init_app(app)

conn = mysql.connect()
conn.autocommit(True)
cursor = conn.cursor()

from app import User, Forum, Thread, Post, General
Пример #36
0
class Database():

    def __init__(self, app):
        self.mysql = MySQL()
        self.mysql.init_app(app)

    def get_all_users(self):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT username, email, password FROM Users WHERE is_active = True"""
        cursor.execute(query)
        rows = cursor.fetchall()
        cursor.close()
        users = []
        for row in rows:
            users.append(User(row[0], row[1], row[2]))
        #self.mysql.get_db().close()
        return users


    def get_user(self, username=None, email=None, password=None):
        if email is None and username is None:
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        first = True
        query = """SELECT username, email, password, is_active FROM Users WHERE """
        if username:
            query += """username = '******'""" % (username)
            first = False
        if email:
            if not first:
                query += """ AND """
            query += """email = '%s'""" % (email)
            first = False
        if password:
            if not first:
                query += """ AND """
            query += """password = '******'""" % (password)
        cursor.execute(query)
        u = cursor.fetchone()
        cursor.close()
        #self.mysql.get_db().close()
        if not u:
            return None
        return User(u[0], u[1], u[2], u[3])

    def insert_user(self, username, email, password):
        if (not (username and email and password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """INSERT INTO Users (username, email, password) VALUES ('%s', '%s', '%s')""" % (username, email, password)
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        #self.mysql.get_db().close()
        return User(username, email, password)

    def update_user(self, username, email=None, password=None, is_active=True):
        if (not (username) or not (email or password)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """UPDATE Users SET is_active = %s""" % (str(is_active))
        if email:
            statement += """, email = '%s'""" % email
        if password:
            statement += """, password = '******'""" % password
        statement += """ WHERE username = '******'""" % username
        cursor.execute(statement)
        self.mysql.get_db().commit()
        cursor.close()
        #self.mysql.get_db().close()
        return User(username, email, password)


    def get_all_players(self):
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        query = """SELECT player_id, first_name, last_name, nfl_team FROM Players"""
        cursor.execute(query)
        rows = cursor.fetchall()
        cursor.close()
        players = []
        for row in rows:
            players.append(Player(row[0], row[1], row[2], row[3]))
        #self.mysql.get_db().close()
        return players


    def get_player(self, player_id=None, first_name=None, last_name=None, nfl_team=None):
        if player_id is None and first_name is None and last_name is None and nfl_team is None:
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        first = True
        query = """SELECT player_id, first_name, last_name, nfl_team FROM Players WHERE """
        if player_id:
            query += """player_id = '%s'""" % (player_id)
            first = False
        if first_name:
            if not first:
                query += """ AND """
            query += """first_name = '%s'""" % (first_name)
            first = False
        if last_name:
            if not first:
                query += """ AND """
            query += """last_name = '%s'""" % (last_name)
            first = False
        if nfl_team:
            if not first:
                query += """ AND """
            query += """nfl_team = '%s'""" % (nfl_team)
            first = False
        cursor.execute(query)
        p = cursor.fetchone()
        cursor.close()
        #self.mysql.get_db().close()
        if not p:
            return None
        return Player(p[0], p[1], p[2], p[3])

    def insert_player(self, player_id, first_name, last_name, nfl_team):
        if (not (player_id and first_name and nfl_team)):
            return None
        self.mysql.before_request()
        cursor = self.mysql.get_db().cursor()
        statement = """INSERT INTO Players (player_id, first_name, last_name, nfl_team) VALUES ('%s', '%s', '%s', '%s')""" % \
                        (player_id, first_name, last_name, nfl_team)
        try:
            cursor.execute(statement)
            self.mysql.get_db().commit()
            cursor.close()
            self.mysql.get_db().close()
        except Exception, e:
            print e
        return Player(player_id, first_name, last_name, nfl_team)
Пример #37
0
#     _password = request.form['inputPassword']
 
#     # validate the received values
#     if _name and _email and _password:
#         return json.dumps({'html':'<span>All fields good !!</span>'})
#     else:
#         return json.dumps({'html':'<span>Enter the required fields</span>'})

# if __name__ == '__main__':
#     app.run()

from flask import Flask, render_template, json, request
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash

mysql = MySQL()
app = Flask(__name__)

# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'Bucketlist'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)

# the toolbar is only enabled in debug mode:
app.debug = True

# set a 'SECRET_KEY' to enable the Flask session cookies
app.config['SECRET_KEY'] = '<replace with a secret key>'
Пример #38
0
 def __init__(self, app):
     self.mysql = MySQL()
     self.mysql.init_app(app)
Пример #39
0
from flask import Flask, render_template, request, json, session, redirect
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash, secure_filename
import os, pygame
from Queue import *

app = Flask(__name__)

app.secret_key = 'why would I tell you my secret key?'

mysql = MySQL()

# q = Queue()
q = []
current_song = ''
prev_song = ''

# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'Music'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)

import thread
import threading

lock = threading.Lock()


def remove_elemnt():
Пример #40
0
import datetime
from flask import Flask, json, request, session, redirect, url_for, abort, render_template, flash
from contextlib import closing
from flask.ext.mysql import MySQL

app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'tododb'
app.config['MYSQL_DATABASE_HOST'] = '23.253.70.25'
app.config['MYSQL_DATABASE_PORT'] = 3306
db = MySQL()
db.init_app(app)

# ROUTES
# Index page gets passed on information about tasks
@app.route("/")
def index():
    conn = db.connect()
    cursor = conn.cursor()
    cursor.callproc('get_table', ())
    tasks = [dict(id=row[0], title=row[1], descr=row[2], done=row[3], dline=row[4], finish=row[5]) for row in cursor.fetchall()]
    cursor.close() 
    conn.close()
    return render_template('index.html', tasks=tasks)


# Adds new task to list and stores relevant information
@app.route('/add', methods=['POST'])
def add_entry():
    _title = request.form['title']