After some more research, I found the mysql error code to be in err.orig.args[0]
. So the Answer is:
try:
engine.scalar(select([1]))
except sqlalchemy.exc.OperationalError as err:
if err.orig.args[0] == 1045:
print("Access Denied")
elif err.orig.args[0] == 2003:
print("Connection Refused")
else:
raise
Try err.args[0]
try:
engine.scalar(select([1]))
except sqlalchemy.exc.OperationalError as err:
if err.args[0] == 1045:
print("Access Denied")
elif err.args[0] == 2003:
print("Connection Refused")
else:
raise
As OperationalError wraps DBAPIError, that has a code
argument. Most likely just replace args[0]
with code
. Like so:
try:
engine.scalar(select([1]))
except sqlalchemy.exc.OperationalError as err:
if err.code == 1045:
print("Access Denied")
elif err.code == 2003:
print("Connection Refused")
else:
raise
I made a python virtualenv using python3.6. Then I installed rasa and rasa x: pip install rasa pip install rasa-x --extra-index-url Simple Index,pip install rasa-x==0.39.3 --extra-index-url https://pypi.rasa.com/simple,I have tried this action, it took too long time to install all the packages and the whole installation procedure was always blocked by mutiple versions selection of pip. I have not finished the full installation yet up to now:,I run rasa init to initiate a new project and trained it. When I started rasa x in this project folder, I got a strange problem:
For Rasa Open Source:
`pip install rasa==2.8.1`
`pip install rasa-sdk==2.8.1'
Ref: anycodings_python-3.x https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads,It creates the tables in the database anycodings_python-3.x (there are ways of using SQLAlchemy with anycodings_python-3.x preexisting tables, so an explicit anycodings_python-3.x instruction isd necessary).,In case it ends up helping someone, my anycodings_python-3.x issue was due to using an in memory anycodings_python-3.x sqlite db to unittest an API. Pytest anycodings_python-3.x would set up the database and tables anycodings_python-3.x with one connection while the API would anycodings_python-3.x create its own separate connection when anycodings_python-3.x the test were hitting endpoints. This anycodings_python-3.x ultimately solved it for me.,Is there a way to update a document with a Painless script without changing the order of unaffected fields?
You can try run this code too.
import enum
from sqlalchemy
import create_engine, Column, Integer, String, Enum
from sqlalchemy.ext.declarative
import declarative_base
from sqlalchemy.orm
import sessionmaker
engine = create_engine('sqlite:///:memory:', echo = True)
Base = declarative_base()
Session = sessionmaker(bind = engine)
session = Session()
class Type(str, enum.Enum):
ONE = "one"
TWO = "two"
class Item(Base):
__tablename__ = 'items'
id = Column(Integer, primary_key = True, index = True)
name = Column(String, unique = True, index = True)
type = Column(Enum(Type),
default = Type.ONE, nullable = False)
item = Item(name = "item_name", type = "one")
session.add(item)
print(Item.__table__)
session.commit()
for name in session.query(Item.name):
print(name)
I added:
engine = create_engine('sqlite:///:memory:', echo = True)
Base = declarative_base()
Base.metadata.create_all(bind = engine)
Session = sessionmaker(bind = engine)
session = Session()
In case it ends up helping someone, my anycodings_python-3.x issue was due to using an in memory anycodings_python-3.x sqlite db to unittest an API. Pytest anycodings_python-3.x would set up the database and tables anycodings_python-3.x with one connection while the API would anycodings_python-3.x create its own separate connection when anycodings_python-3.x the test were hitting endpoints. This anycodings_python-3.x ultimately solved it for me.
engine = create_engine("sqlite:///:memory:", poolclass = StaticPool, connect_args = {
'check_same_thread': False
})