@@ 175-200 (lines=26) @@ | ||
172 | conn.close() |
|
173 | return result |
|
174 | ||
175 | def return_all(): |
|
176 | query = """select array_to_json(array_agg(row_to_json(t))) from ( |
|
177 | SELECT * FROM tb_users) t""" |
|
178 | ||
179 | conn = None |
|
180 | result = None |
|
181 | ||
182 | try: |
|
183 | params = dbconfig(filename, section) |
|
184 | ||
185 | conn = psycopg2.connect(**params) |
|
186 | ||
187 | cur = conn.cursor() |
|
188 | cur.execute(query) |
|
189 | ||
190 | result = cur.fetchall() |
|
191 | ||
192 | cur.close() |
|
193 | ||
194 | ||
195 | except (Exception, psycopg2.DatabaseError) as error: |
|
196 | print (error) |
|
197 | finally: |
|
198 | if conn is not None: |
|
199 | conn.close() |
|
200 | return result |
|
201 | ||
202 | current_user = find_by_username("[email protected]") |
|
203 |
@@ 65-90 (lines=26) @@ | ||
62 | conn.close() |
|
63 | return result |
|
64 | ||
65 | def return_all(): |
|
66 | query = """select array_to_json(array_agg(row_to_json(t))) from ( |
|
67 | SELECT * FROM tb_users) t""" |
|
68 | ||
69 | conn = None |
|
70 | result = None |
|
71 | ||
72 | try: |
|
73 | params = dbconfig(filename, section) |
|
74 | ||
75 | conn = psycopg2.connect(**params) |
|
76 | ||
77 | cur = conn.cursor() |
|
78 | cur.execute(query) |
|
79 | ||
80 | result = cur.fetchall() |
|
81 | ||
82 | cur.close() |
|
83 | ||
84 | ||
85 | except (Exception, psycopg2.DatabaseError) as error: |
|
86 | print (error) |
|
87 | finally: |
|
88 | if conn is not None: |
|
89 | conn.close() |
|
90 | return result |
|
91 | ||
92 | ||
93 | def hash_password(password): |