Skip to content

Commit 99fd948

Browse files
committed
add example app
1 parent 9aae17b commit 99fd948

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/app.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)