Skip to content

Instantly share code, notes, and snippets.

@rob137
Created March 11, 2019 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob137/fd571070608efb203419f6b45e7e41e0 to your computer and use it in GitHub Desktop.
Save rob137/fd571070608efb203419f6b45e7e41e0 to your computer and use it in GitHub Desktop.
rob@rob-XPS-13-9370  ~/proof-of-concept/sensor_api   master  python3 flask_api.py
/home/rob/.local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
* Serving Flask app "flask_api" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
/home/rob/.local/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
* Debugger is active!
* Debugger PIN: 309-333-606
{'end_time': '10.10.2018 16:02:17', 'interval': '5sec', 'sensor': 'gps', 'vehicle': 'fv1', 'start_time': '10.10.2018 15:30:52'}
{'end_time': '04.10.2018 17:45:17', 'interval': '5sec', 'sensor': 'gps', 'vehicle': 'fv1', 'start_time': '04.10.2018 17:40:52'}
1539181852000000000
1538671252000000000
[2019-03-11 15:31:53,720] ERROR in app: Exception on /telemetry/rangewithres [POST]
Traceback (most recent call last):
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1230, in _execute_context
cursor, statement, parameters, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
psycopg2.ProgrammingError: column gps.trip_id does not exist
LINE 1: ...date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_i...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/rob/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/rob/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/api.py", line 325, in wrapper
resp = resource(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/webargs/core.py", line 450, in wrapper
return func(*new_args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/marshalling.py", line 136, in wrapper
resp = f(*args, **kwargs)
File "/home/rob/proof-of-concept/sensor_api/api_resources.py", line 135, in post
result = set_vehicle.query(set_sensor).filter(set_sensor.timestamp.between(timestampx, timestampy)).first()
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3010, in first
ret = list(self[0:1])
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2800, in __getitem__
return list(res)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3112, in __iter__
return self._execute_and_instances(context)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3137, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 974, in execute
return meth(self, multiparams, params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 273, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1093, in _execute_clauseelement
distilled_params,
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1234, in _execute_context
e, statement, parameters, cursor, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1452, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 296, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 276, in reraise
raise value.with_traceback(tb)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1230, in _execute_context
cursor, statement, parameters, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column gps.trip_id does not exist
LINE 1: ...date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_i...
^
[SQL: 'SELECT gps.timestamp AS gps_timestamp, gps.topic AS gps_topic, gps.readable_date AS gps_readable_date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_id AS gps_trip_id \nFROM gps \nWHERE gps.timestamp BETWEEN %(timestamp_1)s AND %(timestamp_2)s \n LIMIT %(param_1)s'] [parameters: {'timestamp_1': 1539181852000000000, 'timestamp_2': 1539181857000000000, 'param_1': 1}] (Background on this error at: http://sqlalche.me/e/f405)
127.0.0.1 - - [11/Mar/2019 15:31:53] "POST /telemetry/rangewithres HTTP/1.1" 500 -
[2019-03-11 15:31:53,720] ERROR in app: Exception on /telemetry/rangewithres [POST]
Traceback (most recent call last):
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1230, in _execute_context
cursor, statement, parameters, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
psycopg2.ProgrammingError: column gps.trip_id does not exist
LINE 1: ...date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_i...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/rob/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/rob/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/api.py", line 325, in wrapper
resp = resource(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/webargs/core.py", line 450, in wrapper
return func(*new_args, **kwargs)
File "/home/rob/.local/lib/python3.6/site-packages/flask_restplus/marshalling.py", line 136, in wrapper
resp = f(*args, **kwargs)
File "/home/rob/proof-of-concept/sensor_api/api_resources.py", line 135, in post
result = set_vehicle.query(set_sensor).filter(set_sensor.timestamp.between(timestampx, timestampy)).first()
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3010, in first
ret = list(self[0:1])
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2800, in __getitem__
return list(res)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3112, in __iter__
return self._execute_and_instances(context)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3137, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 974, in execute
return meth(self, multiparams, params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 273, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1093, in _execute_clauseelement
distilled_params,
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1234, in _execute_context
e, statement, parameters, cursor, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1452, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 296, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 276, in reraise
raise value.with_traceback(tb)
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1230, in _execute_context
cursor, statement, parameters, context
File "/home/rob/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 536, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column gps.trip_id does not exist
LINE 1: ...date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_i...
^
[SQL: 'SELECT gps.timestamp AS gps_timestamp, gps.topic AS gps_topic, gps.readable_date AS gps_readable_date, gps.raw_sensor_data AS gps_raw_sensor_data, gps.trip_id AS gps_trip_id \nFROM gps \nWHERE gps.timestamp BETWEEN %(timestamp_1)s AND %(timestamp_2)s \n LIMIT %(param_1)s'] [parameters: {'timestamp_1': 1538671252000000000, 'timestamp_2': 1538671257000000000, 'param_1': 1}] (Background on this error at: http://sqlalche.me/e/f405)
127.0.0.1 - - [11/Mar/2019 15:31:53] "POST /telemetry/rangewithres HTTP/1.1" 500 -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment