在下目前刚开始接触
用官方范例
但是却无法写入
qqq.py
import sys
sys.path.append("/var/www/html/ft/ft2")
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import dbtest
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://frank:1qaz2wsx#EDC@localhost/mydb'
db = SQLAlchemy(app)
if __name__ == '__main__':
db.create_all()
而错误信息如下:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 936, in _do_get
return self._pool.get(wait, self._timeout)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/queue.py", line 145, in get
raise Empty
sqlalchemy.util.queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 89, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/default.py", line 376, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: Ident authentication failed for user "frank"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "qqq.py", line 11, in <module>
db.create_all()
File "/usr/local/lib/python3.3/site-packages/flask_sqlalchemy/__init__.py", line 856, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/usr/local/lib/python3.3/site-packages/flask_sqlalchemy/__init__.py", line 848, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), tables=tables)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/sql/schema.py", line 3317, in create_all
tables=tables)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1554, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "/usr/local/lib/python3.3/contextlib.py", line 48, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1547, in _optional_conn_ctx_manager
with self.contextual_connect() as conn:
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1737, in contextual_connect
self.pool.connect(),
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 332, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 630, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 433, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 949, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 278, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 404, in __init__
self.connection = self.__connect()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 530, in __connect
connection = self.__pool._creator()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 95, in connect
connection_invalidated=invalidated
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/compat.py", line 178, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/compat.py", line 171, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 89, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/default.py", line 376, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
sqlalchemy.exc.OperationalError: (OperationalError) FATAL: Ident authentication failed for user "frank"
None None
[root@sinyi-tech ft2]# vi qqq.py
[root@sinyi-tech ft2]# vi qqq.py
[root@sinyi-tech ft2]# python qqq.py
Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 936, in _do_get
return self._pool.get(wait, self._timeout)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/queue.py", line 145, in get
raise Empty
sqlalchemy.util.queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 89, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/default.py", line 376, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: Ident authentication failed for user "frank"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "qqq.py", line 11, in <module>
db.create_all()
File "/usr/local/lib/python3.3/site-packages/flask_sqlalchemy/__init__.py", line 856, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/usr/local/lib/python3.3/site-packages/flask_sqlalchemy/__init__.py", line 848, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), tables=tables)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/sql/schema.py", line 3317, in create_all
tables=tables)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1554, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "/usr/local/lib/python3.3/contextlib.py", line 48, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1547, in _optional_conn_ctx_manager
with self.contextual_connect() as conn:
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1737, in contextual_connect
self.pool.connect(),
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 332, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 630, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 433, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 949, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 278, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 404, in __init__
self.connection = self.__connect()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/pool.py", line 530, in __connect
connection = self.__pool._creator()
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 95, in connect
connection_invalidated=invalidated
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/compat.py", line 178, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/util/compat.py", line 171, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/strategies.py", line 89, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/SQLAlchemy-0.9.6-py3.3-linux-x86_64.egg/sqlalchemy/engine/default.py", line 376, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.3/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
sqlalchemy.exc.OperationalError: (OperationalError) FATAL: Ident authentication failed for user "frank"
None None