写完代码与逆行之后发现的问题;
为啥会一直提示找不到指定程序
> D:\Anaconda3\python.exe D:/pythonProject/python_space/mydjango/cmdb/admin.py
Traceback (most recent call last):
File "D:/pythonProject/python_space/mydjango/cmdb/admin.py", line 51, in <module>
Base.metadata.create_all(engine)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\sql\schema.py", line 4005, in create_all
tables=tables)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1939, in _run_visitor
with self._optional_conn_ctx_manager(connection) as conn:
File "D:\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1932, in _optional_conn_ctx_manager
with self.contextual_connect() as conn:
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2123, in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2158, in _wrap_pool_connect
return fn()
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 403, in connect
return _ConnectionFairy._checkout(self)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 791, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 532, in checkout
rec = pool._do_get()
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 1196, in _do_get
self._dec_overflow()
File "D:\Anaconda3\lib\site-packages\sqlalchemy\util\langhelpers.py", line 66, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 249, in reraise
raise value
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 1193, in _do_get
return self._create_connection()
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 350, in _create_connection
return _ConnectionRecord(self)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 477, in __init__
self.__connect(first_connect_check=True)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\pool.py", line 674, in __connect
connection = pool._invoke_creator(self)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\strategies.py", line 106, in connect
return dialect.connect(*cargs, **cparams)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 412, in connect
return self.dbapi.connect(*cargs, **cparams)
File "D:\Anaconda3\lib\site-packages\pymysql\connections.py", line 353, in __init__
self.connect()
File "D:\Anaconda3\lib\site-packages\pymysql\connections.py", line 633, in connect
self._request_authentication()
File "D:\Anaconda3\lib\site-packages\pymysql\connections.py", line 932, in _request_authentication
auth_packet = _auth.caching_sha2_password_auth(self, auth_packet)
File "D:\Anaconda3\lib\site-packages\pymysql\_auth.py", line 265, in caching_sha2_password_auth
data = sha2_rsa_encrypt(conn.password, conn.salt, conn.server_public_key)
File "D:\Anaconda3\lib\site-packages\pymysql\_auth.py", line 147, in sha2_rsa_encrypt
rsa_key = serialization.load_pem_public_key(public_key, default_backend())
File "D:\Anaconda3\lib\site-packages\cryptography\hazmat\backends\__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "D:\Anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "D:\Anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 117, in <module>
from cryptography.hazmat.bindings.openssl import binding
File "D:\Anaconda3\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 14, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: 找不到指定的程序。
Process finished with exit code 1
>
不知道为啥找了很久也没办法解决,之前也用过还好好的。
求助各位大神,谢谢啦
```python
# 调用Column创建字段 加类型
from sqlalchemy import Table, Column, Integer, String, ForeignKey
# 调用操作链接,反查
from sqlalchemy.orm import relationship
# 调用基类Base
from sqlalchemy.ext.declarative import declarative_base
# 调用链接数据库
from sqlalchemy import create_engine
# 创建一个连接
engine = create_engine("mysql+pymysql://wu:123456@localhost:3306/wu", encoding="utf-8")
# 创建一个orm基类
Base = declarative_base()
# 创建表结构
class UserTable(Base):
__tablename__ = 'user'
username = Column(String(32), primary_key=True)
password = Column(String(32))
identify = Column(String(5))
def __repr__(self):
return "User(name=%s,fullname=%s,password=%s" % (self.username, self.password, self.identify)
class InfoManage(Base):
__tablename__ = 'info'
id = Column(Integer, primary_key=True)
hostname = Column(String(32))
port = Column(String(16))
address = Column(String(16))
status = Column(String)
tran_speed = Column(String)
DNS = Column(String)
key = Column(Integer)
def __repr__(self):
return "id:%s" % self.id
# 创建表
Base.metadata.create_all(engine)
上面是我的代码