Example #1
0
	def testData(self):
		"""
		Try to create record in a table Data
		"""
		data = Data(task_id = ids.pop(), side = "left")
		db.session.add(data)
		data.sha = "somedata"
		db.session.commit()
Example #2
0
	def testInvalidData(self):
		"""
		Try to create record in a table Data
		"""
		try:
			data = Data(task_id = ids.pop(), side = "fake")
		except InvalidValue:
			return
		raise Exception("fake value is not acceptable for side column")
Example #3
0
def insert():
    if request.method == 'POST':
        name = request.form['name']
        length = int(request.form['length'])
        x = int(request.form['x'])
        y = int(request.form['y'])
        square = x * y * length

        my_data = Data(name, length, x, y, square)
        db.session.add(my_data)
        db.session.commit()

        flash("Polygon Inserted Successfully")

        return redirect(url_for('index'))
Example #4
0
from app import Data, db

URL = "http://data.jyvaskyla.fi/tiedostot/kevyt_liikenne_laskurit_vrk.csv"
STREAM = urllib.request.urlopen(URL)
CSVFILE = csv.reader(codecs.iterdecode(STREAM, "utf-8"))
next(CSVFILE, None)
LOCATIONS = [
    "Kinakujan silta",
    "JK-1",
    "PP-1",
    "Matkakeskus",
    "Satama",
    "JK-2",
    "PP-2",
    "Tourula",
    "JK-3",
    "PP-3",
    "Vaajakoskentie_Jyska",
]
for line in CSVFILE:
    print("=======")
    d = datetime.datetime.strptime(line[0], "%d/%m/%Y").date().isoformat()
    count = 2
    for location in LOCATIONS:
        print(line[0])
        print(location + " " + line[count])
        r = Data(date=d, qty=line[count], location=location)
        count = count + 1
        db.session.add(r)
        db.session.commit()
Example #5
0
def delete_data():
    data, status_code = Data.delete_data()
    return data, status_code
Example #6
0
def patch_data():
    data, status_code = Data.patch_data(request)
    return data, status_code
Example #7
0
def post_data():
    data, status_code = Data.set_data(request)
    return data, status_code
Example #8
0
def get_data():
    data = Data.get_data()
    return data