Skip to content
Snippets Groups Projects
Commit 92c0a9ce authored by Jan Müller's avatar Jan Müller
Browse files

Edit nest table desing

parent 23cde5d7
No related branches found
No related tags found
1 merge request!4Feature/add arbor support
Pipeline #163334 failed
......@@ -31,7 +31,7 @@ def SetupNestTables(postgres_username, postgres_password, port):
cur.execute('''CREATE TABLE MULTIMETERS (
MULTIMETER_ID INT PRIMARY KEY NOT NULL UNIQUE,
ATTRIBUTE CHAR(50) );''')
ATTRIBUTE VARCHAR(50) );''')
cur.execute('''CREATE TABLE GIDS (
GID INT PRIMARY KEY NOT NULL UNIQUE,
......
......@@ -48,8 +48,8 @@ def nest_get_gids_in_population(population_id): # noqa: E501
:rtype: List[int]
"""
con = connect_to_database()
cur = con.cursor()
cur.execute("SELECT GID FROM GIDS WHERE GIDS.POPULATION_ID ="+str(population_id))
gids = [i[0] for i in cur.fetchall()]
......@@ -68,21 +68,19 @@ def nest_get_multimeter_info(): # noqa: E501
con = connect_to_database()
cur = con.cursor()
cur.execute("SELECT MULTIMETER_ID FROM MULTIMETERS")
mult_ids = cur.fetchall()
ur.execute("SELECT * FROM MULTIMETERS;")
attributes = np.array(cur.fetchall())
cur.execute("SELECT regexp_replace(ATTRIBUTE, '\s+$', '') FROM (SELECT * FROM MULTIMETERS) AS MULT_INFO;")
attributes = cur.fetchall()
gids = []
for id in mult_ids:
for id in attributes[:,0]:
cur.execute("SELECT GID FROM MULT_PER_GID WHERE MULTIMETER_ID = %s", (id,))
gids.append([i[0] for i in cur.fetchall()])
mult_info = []
for i in range(len(mult_ids)):
mult_info.append({"id": mult_ids[i][0],
"attributes": attributes[i][0],
for i in range(len(attributes)):
mult_info.append({"id": attributes[i][0],
"attributes": attributes[i][1],
"gids": gids[i]})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment