We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9aae17b commit 99fd948Copy full SHA for 99fd948
examples/app.py
@@ -0,0 +1,27 @@
1
+from flask import Flask
2
+from flask_postgresql import PostgreSQL
3
+
4
+app = Flask(__name__)
5
+app.config["PG_HOST"] = "192.168.99.103"
6
+app.config["PG_USERNAME"] = "test"
7
+app.config["PG_PASSWORD"] = "test"
8
+app.config["PG_DB"] = "test"
9
+app.config["PG_PORT"] = "5432"
10
11
+db = PostgreSQL(app)
12
13
14
+@app.route("/")
15
+def users():
16
+ connection = db.connection
17
18
+ with connection:
19
+ with connection.cursor() as curs:
20
+ curs.execute("""select usename from pg_catalog.pg_user""")
21
+ data = curs.fetchone()
22
23
+ return data[0]
24
25
26
+if __name__ == "__main__":
27
+ app.run(debug=True)
0 commit comments