from flask import Flask, jsonify
from flask import request
from slotscal import results
from flask_sqlalchemy import SQLAlchemy
import time
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']= 'postgresql://postgres:test123@localhost:5432/flask'
db=SQLAlchemy(app)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hamza/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 1094, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/home/hamza/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 1086, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/home/hamza/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 1017, in get_engine
return connector.get_engine()
File "/home/hamza/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 592, in get_engine
sa_url = make_url(uri)
File "/home/hamza/.local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 694, in make_url
return _parse_rfc1738_args(name_or_url)
File "/home/hamza/.local/lib/python3.8/site-packages/sqlalchemy/engine/url.py", line 755, in _parse_rfc1738_args
raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'postgresql:/test123@localhost/flask'发布于 2021-06-15 09:58:30
连接字符串必须是libpq连接字符串,其语法为is documented in the PostgreSQL documentation。
如果您使用URL表单,则必须遵守RFC 1738。特别是,在postgresql:之后需要两个斜杠
postgresql://test123@localhost/flaskhttps://stackoverflow.com/questions/67977224
复制相似问题