我成功地使用flask_session 創建了一個會話表,但現在我需要在PostgreSQL 資料庫中設定模式名稱。我該如何設定?
def create_app():
app = Flask(__name__)
cors = CORS(app, resources={r"/*": {"origins": "http://localhost:8080/"}})
app.config['SESSION_TYPE'] = 'sqlalchemy'
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:password@localhost:5432/database'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config["SESSION_SQLALCHEMY_TABLE"] = "sessions" #default sessions
app.config["SESSION_COOKIE_SECURE"] = True
app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(seconds=50)
session = Session(app)
session.app.session_interface.db.create_all()
return app
uj5u.com熱心網友回復:
已解決,通過將選項引數添加到 url。
postgresql://postgres:password@localhost:5432/database?options=-c search_path=schema_name
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/365942.html
標籤:PostgreSQL的 烧瓶 烧瓶-sqlalchemy psycopg2 烧瓶会话
