- api data queries
This commit is contained in:
parent
a7b80c4c8d
commit
941d2006a1
4 changed files with 136 additions and 101 deletions
|
|
@ -10,11 +10,12 @@ import os
|
|||
# currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
# parentdir = os.path.dirname(currentdir)
|
||||
# sys.path.insert(0, parentdir)
|
||||
# import requests
|
||||
from sqlalchemy.orm import session
|
||||
from models import ObservationSchema, Person, PersonSchema, Observation
|
||||
|
||||
from gschliefgraben_glasfaser.models import ObservationSchema, Person, PersonSchema, Observation
|
||||
from gschliefgraben_glasfaser.my_api import MyApi
|
||||
from db.pg_models import create_pg_session
|
||||
from myApi import myAPI
|
||||
import requests
|
||||
#from models import Person, PersonSchema
|
||||
# response = requests.get('https://api.com/')
|
||||
# print(response) # shows the response's HTTP status code
|
||||
|
|
@ -28,18 +29,18 @@ def main():
|
|||
print(db_user)
|
||||
|
||||
pg_session: session = create_pg_session()
|
||||
pg_person: Person = pg_session.query(Person).first()
|
||||
#observation: Observation = pg_session.query(Observation).first()
|
||||
print(pg_person)
|
||||
# pg_person: Person = pg_session.query(Person).first()
|
||||
observation: Observation = pg_session.query(Observation).first()
|
||||
# print(pg_person)
|
||||
|
||||
# serialize db data to json
|
||||
person_schema = PersonSchema()
|
||||
dump_data = person_schema.dump(pg_person)
|
||||
print(dump_data)
|
||||
# serialize db data to json
|
||||
# observation_schema = ObservationSchema()
|
||||
# dump_data = observation_schema.dump(observation)
|
||||
# person_schema = PersonSchema()
|
||||
# dump_data = person_schema.dump(pg_person)
|
||||
# print(dump_data)
|
||||
# serialize db data to json
|
||||
observation_schema = ObservationSchema()
|
||||
dump_data = observation_schema.dump(observation)
|
||||
print(dump_data)
|
||||
|
||||
# # deserialize
|
||||
# load_data: Person = person_schema.load(dump_data)
|
||||
|
|
@ -57,7 +58,9 @@ def main():
|
|||
# data='grant_type=client_credentials&scope=gschliefgraben')
|
||||
# print(response)
|
||||
token_api = os.environ.get("TOKEN_API")
|
||||
test = myAPI(token_api)
|
||||
test_api = MyApi(token_api)
|
||||
data = test_api.getSensorData("inclino1_14")
|
||||
print(data)
|
||||
|
||||
# create(dump_data)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue