我正在用我编写的一些代码进行以下(相对)简单的调用:
pickups = session.query(Pickup).filter(Pickup.firebase_run_id == run_id).all()
我对此代码有两组集成测试,一组在本地运行并使用psycops2
TLS,另一组在 GCP 开发环境(GCP 云功能)中运行并使用pg8000
UNIX 套接字(GCP 要求(?)云功能通过 UNIX 套接字连接到 Cloud SQL - 请参见此处)。本地集成测试运行良好。但是,开发测试可靠地失败并出现以下错误:
Traceback (most recent call last):
File "/user_code/main.py", line 245, in GET_run
response = run_get(run_id)
File "/user_code/rubbish_geo_client/ops.py", line 686, in run_get
pickups = session.query(Pickup).filter(Pickup.firebase_run_id == run_id).all()
File "/env/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3319, in all
return list(self)
File "/env/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3481, in __iter__
return self._execute_and_instances(context)
File "/env/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3503, in _execute_and_instances
querycontext, self._connection_from_session, close_with_result=True
TypeError: expected bytes, str found
这个特定的函数调用实际上只是这种失败的一个例子;我所有的数据库调用都失败并出现相同的_execute_and_instances
错误!
也许有人对解决此问题的方法有所了解?