在使用SQLAlchemy调用mysql数据库时报错

此报错的环境为:Python3.6.6 pychar2018.2

在pychar中编写的书程序如下:
from flask_sqlalchemy import SQLAlchemy
from flaskapp import app

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymsql://root:111111@127.0.0.1:3306/test'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

db = SQLAlchemy(app)

class Role(db.Model):
tablename ='roles'
id = db.Column(db.Integer,primary_key=True,autoincrement=True,nullable=False)
name = db.Column(db.String(32),unique=True,nullable=False)
if name == '__main__':
#创建一个roles表
db.create_all()

但是在运行后报的错误为:sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:mysql.pymsql

在网上查询相关错误解决方法后,表示没有安装mysql驱动,但是有的帖子说在Python2.7后不用mysql-python。这个环境中已经安装了pymysql。

但是在安装mysql-Python时报如下错误:
图片说明

请问各位大声该如何结局,谢谢!

如能解决我会多付80c币

weixin_42577503
weixin_42577503 你的问题解决了吗?我也遇到了这个问题,不知道怎么解决、、、、
8 个月之前 回复

3个回答

你把 app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymsql://root:111111@127.0.0.1:3306/test'
改成app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:111111@127.0.0.1:3306/test' 试试

qq_30466845
qq_30466845 谢谢你的回复,但是安装你的改了之后报错为:ModuleNotFoundError: No module named 'MySQLdb'
一年多之前 回复
qq_30466845
qq_30466845 谢谢你的回复,我是这是在win7下的环境,那python需要用pip安装哪个模块?
一年多之前 回复

你那个mysql+pymsql少个y所以出现这个问题 正确的应该是mysql+pymysql

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
python使用sqlalchemy连接mysql数据库出错

个人环境是 python2.7,sqlalchemy1.1.6,mysql5.7.18,mysql-python1.2.5。 在pycharm中准备用sqlalchemy连接本地的数据库,连接的代码是: ``` engine = create_engine("mysql+mysqldb://root:root@localhost:3306/test?charset=utf8mb4") DBSession = sessionmaker(bind=engine) session = DBsession() #执行一段查询 res = session.execute("select * from testTable where id = '11' ").fetchall() ``` 然后报错是sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2019, "Can't initialize character set utf8mb4 (path: C:\\mysql\\\\share\\charsets\\)") 查了一下应该是编码的问题,但是我已经修改过数据库的编码,如下所示: ![数据库编码截图](https://img-ask.csdn.net/upload/201705/13/1494616908_610575.jpg) 求大神指教。

SQLAlchemy 访问Mysql数据库乱码问题,如何解决?

1.写了一段使用SQLAlchemy 编程的代码,程序本身没问题,就是访问数据库时产生一个错误提示,但是即使有错误代码页能正常运行,操作结果也正确。这个错误是关于代码编码方式的错误,但是调了很长时间这个错误就是不能消除,求解救2.这里是代码:(1)orm.py from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column,Integer,String Base = declarative_base() class Account(Base): __tablename__ = u'account' id = Column(Integer,primary_key = True) salary = Column(Integer) username = Column(String(20),nullable = False) password = Column(String(200),nullable = False) title = Column(String(50)) def is_active(self): return True def get_id(self): return self.id def is_authenticated(self): return True def is_anonymous(self): return False from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session,sessionmaker db_connect_string = 'mysql://root:admin@localhost:3306/test_database?charset=utf8' ssl_args = {'ssl':{'cert':'/home//ssl/client-cert.pem', 'key':"/home/shouse/ssl/client-cert.pem", 'ca':'/home/shouse/ssl/ca-cert.pem'}} engine = create_engine(db_connect_string,connect_args = ssl_args) SessionType = scoped_session(sessionmaker(bind = engine,expire_on_commit = False)) def GetSession(): return SessionType() from contextlib import contextmanager @contextmanager def session_scope(): session = GetSession() try: yield session session.commit() except: session.rollback() raise finally: session.close() (2)databaseoperation.py代码: # -*- coding:utf-8 -*- import orm from sqlalchemy import or_ def InsertAccount(user,password,title,salary): with orm.session_scope() as session: account = orm.Account(username = user,password =password,title = title,salary = salary) session.add(account) def GetAccount(id=None,username = None): with orm.session_scope() as session: return session.query(orm.Account).filter(or_(orm.Account.id==id,orm.Account.username==username)).first() def Delete(username): with orm.session_scope() as session: account = GetAccount(username = username) if account: session.delete(account) def Update(id,username,password,title,salary): with orm.session_scope() as session: account = session.query(orm.Account).filter(orm.Account.id==id).first() if not account:return account.username=username account.password=password account.title = title account.salary = salary InsertAccount('Lliy','123','System Manager',3000) InsertAccount('Rebeca Li','12221','Accountant',3000) GetAccount(2) Delete('David Li') Update(1,'admin','1111','System Admin',2000) 3.错误提示: 4.数据库截图![](https://segmentfault.com/q/1010000007610761?_ea=1399039)

flask框架中sqlalchemy,对数据库里的表增加字段

flask框架中sqlalchemy,对数据库里的表增加字段

python的框架flask 下 SQLAlchemy 如何跨数据库查询表操作?

使用SQLAlchemy 可以绑定多个数据库,需求是: 要在不同的数据库中进行 表的关联查询?不知道能做到不?希望遇到的大神给指导下!谢谢

sqlalchemy 同步数据库问题python

``` from sqlalchemy import create_engine, MetaData from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base engine = create_engine('host':'mysql+pymysql://root:123456@localhost:3306/spider') Base = declarative_base() class BaseModel(Base): __abstract__ = True __metadata__ = MetaData(bind=engine) __table_arhs__ = { 'mysql_engine': 'InnoDb', 'mysql_charset': 'utf8mb4' } session = _Session(autocommit=False) if __name__ == '__main__': BaseModel.__metadata__.create_all() ``` 用 BaseModel.__metadata__.create_all() 不能同步数据库表 其中一个表类如下: ``` from sqlalchemy import Column from sqlalchemy.dialects.mysql import INTEGER, VARCHAR from common.db import BaseModel class CityModel(BaseModel): __tablename__ = 'city' id = Column(INTEGER, primary_key=True) name = Column(VARCHAR(64)) ``` 这样怎么同步mysql 自动生成表? 大佬们

MySQL添加用户时报错,没有password字段

今天在菜鸟教程学mysql时,想往mysql 数据库中的 user 表添加新用户: 报错提示: > MySQL添加用户时报错 'ERROR 1054 (42S22): Unknown column 'password' in 'field list'' ``` INSERT INTO user ( host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'guest', PASSWORD('123456'), 'Y', 'Y', 'Y'); ``` 而我 DESCRIBE user; 后发现确实没有password这个字段 请问该如何解决?

MySQL数据库INNODB引擎优化问题

``` CREATE TABLE `user` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `balance` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8; update user set balance = balance - 1 where id = ? ``` 上面表结构,下面查询语句。表不大,只有上百条数据,但是高并发访问的时候会锁住。请问怎么优化?

flask-sqlalchemy 操作mysql 报错 (2013, 'Lost connection to MySQL server during query')?

场景:小程序登录操作,或者别的请求查询数据库的操作 第一次填好账户,密码点登录的时候就会报502 Bad Gateway 后端日志显示 File "/home/psn/App/www/python3_vir/lib/python3.5/site-packages/MySQLdb/connections.py", line 276, in query _mysql.connection.query(self, query) sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2013, 'Lost connection to MySQL server during query') 再点一次登录又没问题,给我感觉是好久不操作再操作的第一下经常出现这问题 centos7.5 + mysql-5.7.23 + flask + uwsgi +nginx 不知道是什么原因,请大家帮帮忙

什么导致SQLAlchemy访问数据库出现警告

``` from sqlalchemy import create_engine from consts import DB_URI eng = create_engine(DB_URI) with eng.connect() as con: con.execute('drop table if exists users') con.execute('create table users(Id INT PRIMARY KEY AUTO_INCREMENT, ' 'Name VARCHAR(25))') con.execute("insert into users(name) values('xiaoming')") con.execute("insert into users(name) values('wanglang')") rs = con.execute('select * from users') for row in rs: print row ``` consts.py的代码为(用python驱动可以正常连接数据库并操作): ``` HOSTNAME = 'localhost' DATABASE = 'john' USERNAME = 'root' PASSWORD = '123' DB_URI = 'mysql://{}:{}@{}/{}'.format(USERNAME, PASSWORD, HOSTNAME, DATABASE) ``` 出现如下警告: Python27\lib\site-packages\sqlalchemy\engine\default.py:469: Warning: Incorrect string value: '\xD6\xD0\xB9\xFA\xB1\xEA...' for column 'VARIABLE_VALUE' at row 479 cursor.execute(statement, parameters) (1L, 'xiaoming') (2L, 'wanglang') Process finished with exit code 0 数据库为mysql5.7版本 不明白为什么会出现警告,求大神解答!!

怎样使用sqlalchemy ORM对一个已有的表进行查询

我知道正常的查询是这样的: session.query(User).filter_by(name='user1').all() 但是这个的前提是,User类已知。 在表已经存在的前提下,而这个表并不是我用ORM创建的, 我可以使用什么方法进行查询? 假设表名tb_user 比较笨的方法是自己去 show create table tb_user; 然后根据表的结构去创建一个User类。 有没有其他好的办法?

Python使用sqlalchemy进行查询显示warning但是数据无误

系统win10,64位,数据库mysql5.7.19,数据库驱动是pymysql0.7.11,数据库的配置文件里默认编码是utf8mb4,Python2.7 64位。执行的代码如下: ``` engine = create_engine('mysql+pymysql://root:password@localhost:3306/test?charset=utf8mb4') DBSession = sessionmaker(bind=engine) session = DBSession() res = session.execute("select * from user") session.close() ``` 虽然能够进行 相应的查询,包括增删查改也支持中文,数据也没有问题,但是每次操作都会有一次warning: ``` E:\Python2.7\lib\site-packages\pymysql\cursors.py:166: Warning: (1366, u"Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 480") result = self._query(query) ``` 而我的数据根本没有480行,想知道这是为什么。数据库的编码设置如图所示: ![图片说明](https://img-ask.csdn.net/upload/201711/01/1509468443_49383.png) 谢谢大家!

请教一个flask连接mysql方面的问题?

![图片说明](https://img-ask.csdn.net/upload/202005/20/1589964366_892097.jpg)![图片说明](https://img-ask.csdn.net/upload/202005/20/1589964393_498050.jpg) 请问我想通过flask连接mysql数据库创建表 程序没有错误 但是运行以后右边的text里边为什么没有创建的表在里面 求助懂flask的朋友帮助一下 非常感谢

python使用SQLAlchemy的初级问题

代码: ``` from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:xxxxxx@localhost/flasky' app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True db = SQLAlchemy(app) class Role(db.Model): __tablename__ = 'roles' id = db.Column(db.Integer,primary_key = True) name = db.Column(db.String(64), unique = True) users = db.relationship('User', backref = 'role') #这行建立一对多的反向关系时出错 def __repr__(self): return '<Role %r>' % self.name class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key = True) username = db.Column(db.String(64), unique = True) role_id = db.column(db.Integer, db.ForeignKey('roles.id')) def __repr__(self): return '<User %r>' % self.username if __name__ == '__main__': app.run() ``` 出错提示: sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables on relationship Role.users - there are no foreign keys linking these tables. Ensure that referencing columns are associated with a ForeignKey or ForeignKeyConstraint, or specify a 'primaryjoin' expression. ## 提示没有建立外键,但是我明明在User里面建立了一个叫role_id的外键,求解 **__python版本是3.5.0 数据库是mysql**

Flask-sqlalchemy如何设置表的字符集, 存储引擎, 自增长起始值?

Flask-sqlalchemy如何设置表的字符集, 存储引擎, 自增长起始值? 在mysql中, 可在创建表时设置engine=... charset=... auto_increment=... 在Flask-sqlalchemy中创建表时, 如何设置这些属性?

MySQL 的存储引擎区别

一般在现在的MySQL中,存储引擎不光有Innodb ,还有MyISAM ,MEMORY , MERGE等等 那这几中存储引擎的区别 不同有什么?? 在设计数据库时,怎样选择合适的引擎 才能最大限度的发挥相对应的效率??

在docker中运行,连接postgres数据库报错 sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused

postgres服务已经连接 ``` Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:80 chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 80:80 chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:5432 chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker build -t chiral:v1 . Sending build context to Docker daemon 20.96MB Step 1/13 : FROM mcs07/rdkit:latest ---> 03f8370e36cf Step 2/13 : RUN echo deb http://mirrors.aliyun.com/debian stretch main contrib non-free > /etc/apt/sources.list; echo deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free >> /etc/apt/sources.list; echo deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free >> /etc/apt/sources.list; echo deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free >> /etc/apt/sources.list; echo deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib >> /etc/apt/sources.list; echo deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib >> /etc/apt/sources.list && apt-get update && apt-get install python3-pip --assume-yes && pip3 install setuptools-scm && pip3 install --upgrade setuptools && pip3 install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/ xlrd Pillow setuptools sklearn flask numpy pandas psycopg2-binary wtforms==2.2.1 flask-wtf==0.14.2 flask-sqlalchemy==2.4.1 werkzeug==0.16.1 && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone ---> Using cache ---> cf3090a98808 Step 3/13 : WORKDIR /usr/src/app ---> Using cache ---> 87d4100cc593 Step 4/13 : COPY . . ---> 72064b4ad609 Step 5/13 : ENV LISTEN_PORT 5432 ---> Running in c1431f25230d Removing intermediate container c1431f25230d ---> c1bf69d49133 Step 6/13 : EXPOSE 5432 ---> Running in e23534149810 Removing intermediate container e23534149810 ---> 514d5bad82a2 Step 7/13 : ENV DATASOURCE_DBNAME=chiral ---> Running in ff2405f0865c Removing intermediate container ff2405f0865c ---> d4c1c91e74d8 Step 8/13 : ENV DATASOURCE_USER=postgres ---> Running in 9fa8cdbecb95 Removing intermediate container 9fa8cdbecb95 ---> fb5930e31c98 Step 9/13 : ENV DATASOURCE_PASSWORD=wuxiapptec ---> Running in 99f2369a4e1c Removing intermediate container 99f2369a4e1c ---> e9e2566db00b Step 10/13 : ENV DATASOURCE_HOST=localhost ---> Running in ff8e2789fe9f Removing intermediate container ff8e2789fe9f ---> 9697ede791e5 Step 11/13 : ENV DATASOURCE_PORT=5432 ---> Running in fec654683ab2 Removing intermediate container fec654683ab2 ---> 8e8066352df3 Step 12/13 : ENV WEB_PATH= ---> Running in c545308e00fa Removing intermediate container c545308e00fa ---> a97b043d6d40 Step 13/13 : CMD ["python3", "./app.py"] ---> Running in 8f72fd9e39d3 Removing intermediate container 8f72fd9e39d3 ---> dbd5fa324af0 Successfully built dbd5fa324af0 Successfully tagged chiral:v1 SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories. PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 5432:5432 chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? (Background on this error at: http://sqlalche.me/e/e3q8) PS C:\Users\qian_long0101\wuxi_project\Chiral\cas-chiral> docker run -p 80:80 chiral:v1 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./app.py", line 9, in <module> from database import Sample, Recommend, User, app, db File "/usr/src/app/database.py", line 117, in <module> db.drop_all() File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1041, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.7/dist-packages/flask_sqlalchemy/__init__.py", line 1025, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/sql/schema.py", line 4347, in drop_all ddl.SchemaDropper, self, checkfirst=checkfirst, tables=tables File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2057, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/lib/python3.7/contextlib.py", line 112, in __enter__ return next(self.gen) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2049, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2289, in _wrap_pool_connect e, dialect, self File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 1555, in _handle_dbapi_exception_noconnection sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 773, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout rec = pool._do_get() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 139, in _do_get self._dec_overflow() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/impl.py", line 136, in _do_get return self._create_connection() File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__ self.__connect(first_connect_check=True) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 657, in __connect pool.logger.debug("Error on connect(): %s", e) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__ exc_value, with_traceback=exc_tb, File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/pool/base.py", line 652, in __connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/default.py", line 490, in connect return self.dbapi.connect(*cargs, **cparams) File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? ```

python爬虫 mysql数据库提示IntegrityError: (1062, "Duplicate entry

背景:python scrapy框架,mysql(workbench数据库),不同的url设置为主键 根据报错内容,在数据库搜索重复的主键信息,数据库里并没有相关数据,重试,仍提示主键重复 请问这个是什么地方的问题?

python sqlalchemy 如何实现top写法。想按日期倒排序获取前10条记录。

python sqlalchemy 如何实现top写法。想按日期倒排序获取前10条记录。

flask sqlalchemy 查询优化 哪位大神帮忙

``` @admin_blueprint.route('/videos_count') def user_count(): # 视频总数 videos_total = Videos.query.filter(or_(Videos.status == 1, Videos.status== 6)).count() # 月视频更新总数 now = datetime.now() month_first = datetime(now.year, now.month, 1) videos_month = Videos.query. \ filter_by(status=1). \ filter(Videos.created_at >= month_first). \ count() # 日视频更新数 day_first = datetime(now.year, now.month, now.day) videos_day = Videos.query. \ filter_by(status=1). \ filter(Videos.created_at >= day_first). \ count() # 小时视频更新数 video_key = 'videos_count_%d_%d_%d' % (now.year, now.month, now.day) video_prop = ['02:00', '04:00', '06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00', '00:00'] hour_list = [x.split(":")[0] for x in video_prop] hour_list = [datetime(now.year, now.month, now.day, int(y)) for y in hour_list] hour_list.pop() # 生成分段时间轴 month_day = calendar.monthrange(now.year, now.month)[1] if now.day == month_day: hour_list.append(datetime(now.year, now.month + 1, 1, 00)) else: hour_list.append(datetime(now.year, now.month, now.day + 1, 00)) index_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] videos_hour_count = [] for index, hour_first in list(zip(index_list, hour_list)): if index == 0: date_time = (datetime(now.year, now.month, now.day, 00)) videos_hour_num = Videos.query. \ filter(Videos.status == 1, date_time < Videos.created_at, Videos.created_at <= hour_first).\ count() videos_hour_count.append(videos_hour_num) else: videos_hour_num = Videos.query. \ filter(Videos.status == 1, hour_list[index - 1] < Videos.created_at, Videos.created_at <= hour_first).\ count() videos_hour_count.append(videos_hour_num) return render_template('admin/videos_count.html', videos_total=videos_total, videos_month=videos_month, videos_day=videos_day, videos_hour_count=videos_hour_count, videos_hour_list=video_prop ) ``` 这是一段根据时间段,分段的查询,数据比较多,查询一次要一秒,怎么整合成一次查询,或者说把for循环的查询优化,急,打开网页一次要18秒

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

实现简单的文件系统

实验内容: 通过对具体的文件存储空间的管理、文件的物理结构、目录结构和文件操作的实现,加深对文件系统内部功能和实现过程的理解。 要求: 1.在内存中开辟一个虚拟磁盘空间作为文件存储器,在其上实现一个简

MIPS单周期CPU-组成原理实验-华中科技大学

使用logisim布线完成的MIPS单周期CPU,可支持28条指令。跑马灯的代码已经装入了寄存器,可以直接开启时钟运行。

2019数学建模A题高压油管的压力控制 省一论文即代码

2019数学建模A题高压油管的压力控制省一完整论文即详细C++和Matlab代码,希望对同学们有所帮助

基于QT和OpenCV的五子棋实现源码

一个简单的五子棋应用,基于QT和OpenCV的实现源码,通过相邻棋子判断是否获胜,不包含人工智能算法,适合新手入门

Git 实用技巧

这几年越来越多的开发团队使用了Git,掌握Git的使用已经越来越重要,已经是一个开发者必备的一项技能;但很多人在刚开始学习Git的时候会遇到很多疑问,比如之前使用过SVN的开发者想不通Git提交代码为什么需要先commit然后再去push,而不是一条命令一次性搞定; 更多的开发者对Git已经入门,不过在遇到一些代码冲突、需要恢复Git代码时候就不知所措,这个时候哪些对 Git掌握得比较好的少数人,就像团队中的神一样,在队友遇到 Git 相关的问题的时候用各种流利的操作来帮助队友于水火。 我去年刚加入新团队,发现一些同事对Git的常规操作没太大问题,但对Git的理解还是比较生疏,比如说分支和分支之间的关联关系、合并代码时候的冲突解决、提交代码前未拉取新代码导致冲突问题的处理等,我在协助处理这些问题的时候也记录各种问题的解决办法,希望整理后通过教程帮助到更多对Git操作进阶的开发者。 本期教程学习方法分为“掌握基础——稳步进阶——熟悉协作”三个层次。从掌握基础的 Git的推送和拉取开始,以案例进行演示,分析每一个步骤的操作方式和原理,从理解Git 工具的操作到学会代码存储结构、演示不同场景下Git遇到问题的不同处理方案。循序渐进让同学们掌握Git工具在团队协作中的整体协作流程。 在教程中会通过大量案例进行分析,案例会模拟在工作中遇到的问题,从最基础的代码提交和拉取、代码冲突解决、代码仓库的数据维护、Git服务端搭建等。为了让同学们容易理解,对Git简单易懂,文章中详细记录了详细的操作步骤,提供大量演示截图和解析。在教程的最后部分,会从提升团队整体效率的角度对Git工具进行讲解,包括规范操作、Gitlab的搭建、钩子事件的应用等。 为了让同学们可以利用碎片化时间来灵活学习,在教程文章中大程度降低了上下文的依赖,让大家可以在工作之余进行学习与实战,并同时掌握里面涉及的Git不常见操作的相关知识,理解Git工具在工作遇到的问题解决思路和方法,相信一定会对大家的前端技能进阶大有帮助。

实用主义学Python(小白也容易上手的Python实用案例)

原价169,限时立减100元! 系统掌握Python核心语法16点,轻松应对工作中80%以上的Python使用场景! 69元=72讲+源码+社群答疑+讲师社群分享会&nbsp; 【哪些人适合学习这门课程?】 1)大学生,平时只学习了Python理论,并未接触Python实战问题; 2)对Python实用技能掌握薄弱的人,自动化、爬虫、数据分析能让你快速提高工作效率; 3)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; 4)想修炼更好的编程内功,优秀的工程师肯定不能只会一门语言,Python语言功能强大、使用高效、简单易学。 【超实用技能】 从零开始 自动生成工作周报 职场升级 豆瓣电影数据爬取 实用案例 奥运冠军数据分析 自动化办公:通过Python自动化分析Excel数据并自动操作Word文档,最终获得一份基于Excel表格的数据分析报告。 豆瓣电影爬虫:通过Python自动爬取豆瓣电影信息并将电影图片保存到本地。 奥运会数据分析实战 简介:通过Python分析120年间奥运会的数据,从不同角度入手分析,从而得出一些有趣的结论。 【超人气老师】 二两 中国人工智能协会高级会员 生成对抗神经网络研究者 《深入浅出生成对抗网络:原理剖析与TensorFlow实现》一书作者 阿里云大学云学院导师 前大型游戏公司后端工程师 【超丰富实用案例】 0)图片背景去除案例 1)自动生成工作周报案例 2)豆瓣电影数据爬取案例 3)奥运会数据分析案例 4)自动处理邮件案例 5)github信息爬取/更新提醒案例 6)B站百大UP信息爬取与分析案例 7)构建自己的论文网站案例

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

Python界面版学生管理系统

前不久上传了一个控制台版本的学生管理系统,这个是Python界面版学生管理系统,这个是使用pycharm开发的一个有界面的学生管理系统,基本的增删改查,里面又演示视频和完整代码,有需要的伙伴可以自行下

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

linux“开发工具三剑客”速成攻略

工欲善其事,必先利其器。Vim+Git+Makefile是Linux环境下嵌入式开发常用的工具。本专题主要面向初次接触Linux的新手,熟练掌握工作中常用的工具,在以后的学习和工作中提高效率。

JAVA初级工程师面试36问(完结)

第三十一问: 说一下线程中sleep()和wait()区别? 1 . sleep()是让正在执行的线程主动让出CPU,当时间到了,在回到自己的线程让程序运行。但是它并没有释放同步资源锁只是让出。 2.wait()是让当前线程暂时退让出同步资源锁,让其他线程来获取到这个同步资源在调用notify()方法,才会让其解除wait状态,再次参与抢资源。 3. sleep()方法可以在任何地方使用,而wait()只能在同步方法或同步块使用。 ...

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

智鼎(附答案).zip

并不是完整题库,但是有智鼎在线2019年9、10、11三个月的试题,有十七套以上题目,普通的网申行测题足以对付,可以在做题时自己总结一些规律,都不是很难

Visual Assist X 破解补丁

vs a's'sixt插件 支持vs2008-vs2019 亲测可以破解,希望可以帮助到大家

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

JavaWEB商城项目(包括数据库)

功能描述:包括用户的登录注册,以及个人资料的修改.商品的分类展示,详情,加入购物车,生成订单,到银行支付等!另外还有收货地址的和我的收藏等常用操作.环境(JDK 1.7 ,mysql 5.5,Ecli

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

一学即懂的计算机视觉(第一季)

图像处理和计算机视觉的课程大家已经看过很多,但总有“听不透”,“用不了”的感觉。课程致力于创建人人都能听的懂的计算机视觉,通过生动、细腻的讲解配合实战演练,让学生真正学懂、用会。 【超实用课程内容】 课程内容分为三篇,包括视觉系统构成,图像处理基础,特征提取与描述,运动跟踪,位姿估计,三维重构等内容。课程理论与实战结合,注重教学内容的可视化和工程实践,为人工智能视觉研发及算法工程师等相关高薪职位就业打下坚实基础。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/26281 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,但是大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/26281,点击右下方课程资料、代码、课件等打包下载

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

课程主要面向嵌入式Linux初学者、工程师、学生 主要从一下几方面进行讲解: 1.linux学习路线、基本命令、高级命令 2.shell、vi及vim入门讲解 3.软件安装下载、NFS、Samba、FTP等服务器配置及使用

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

快速入门Android开发 视频 教程 android studio

这是一门快速入门Android开发课程,顾名思义是让大家能快速入门Android开发。 学完能让你学会如下知识点: Android的发展历程 搭建Java开发环境 搭建Android开发环境 Android Studio基础使用方法 Android Studio创建项目 项目运行到模拟器 项目运行到真实手机 Android中常用控件 排查开发中的错误 Android中请求网络 常用Android开发命令 快速入门Gradle构建系统 项目实战:看美图 常用Android Studio使用技巧 项目签名打包 如何上架市场

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

相关热词 c#对文件改写权限 c#中tostring c#支付宝回掉 c#转换成数字 c#判断除法是否有模 c# 横向chart c#控件选择多个 c#报表如何锁定表头 c#分级显示数据 c# 不区分大小写替换
立即提问
相关内容推荐