这是我的数据库架构。
\n\n我这样定义我的架构:
\n从 pydantic 导入 BaseModel
\nclass Userattribute(BaseModel):\n name: str\n value: str\n user_id: str\n id: str\nRun Code Online (Sandbox Code Playgroud)\n这是我的模型:
\nclass Userattribute(Base):\n __tablename__ = "user_attribute"\n\n name = Column(String)\n value = Column(String)\n user_id = Column(String)\n id = Column(String, primary_key=True, index=True)\nRun Code Online (Sandbox Code Playgroud)\n在 crud.py 中我定义了一个get_attributes方法。
def get_attributes(db: Session, skip: int = 0, limit: int = 100):\n return db.query(models.Userattribute).offset(skip).limit(limit).all()\nRun Code Online (Sandbox Code Playgroud)\n这是我的GET终点:
@app.get("/attributes/", response_model=List[schemas.Userattribute])\ndef read_attributes(skip: int = 0, limit: int = 100, db: Session = …Run Code Online (Sandbox Code Playgroud) Run Code Online (Sandbox Code Playgroud)>>> import sys >>> sys.set_int_max_str_digits(4300) # Illustrative, this is the default. >>> _ = int('2' * 5432) Traceback (most recent call last): ... ValueError: Exceeds the limit (4300) for integer string conversion: value has 5432 digits.
Python 3.10.7 引入了类型转换的这一重大更改。
文档:整数字符串转换长度限制
其实我不明白为什么
我很难正确导入 firebase SDK。我使用 Vue3 并通过安装 firebaseyarn add firebase
这是我的 firebase.js 文件:
import firebase from 'firebase/app';
Run Code Online (Sandbox Code Playgroud)
但是,这会导致以下错误:1:1 error 'firebase/app' should be listed in the project's dependencies. Run 'npm i -S firebase/app' to add it import/no-extraneous-dependencies
import firebase from 'firebase';
Run Code Online (Sandbox Code Playgroud)
这有效,但我收到以下警告:
It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.
For the module builds, these are …Run Code Online (Sandbox Code Playgroud) 这是我的代码:我想在每次数据更新时在 HelloWorld 组件上创建一个转换。过渡本身工作正常
<transition name="fade">
<p v-if="awesome">Vue is awesome</p>
</transition>
Run Code Online (Sandbox Code Playgroud)
这是我动态创建的“卡片”。
<v-row no-gutters>
<v-col cols="12" sm="4" md="4" v-for="(todo, index) in todos" v-bind:key="index">
<v-card class="pa-2" outlined tile>
<transition name="fade">
<HelloWorld
v-bind:todos="todos"
v-bind:index="index"
v-bind:class="(todos[index].done)?'green':'red'"
/>
</transition>
</v-card>
</v-col>
</v-row>
Run Code Online (Sandbox Code Playgroud)
此处过渡不起作用。
CSS在这里:
<style scoped>
.top {
background: blue;
color: white;
display: flex;
justify-content: space-around;
border-bottom: 2.5px solid black;
}
.fade-enter {
opacity: 0;
}
.fade-enter-active {
transition: opacity 1s;
}
.fade-leave {
}
.fade-leave-active {
transition: 1s;
opacity: 0;
}
</style>
Run Code Online (Sandbox Code Playgroud)
为什么以及如何让它工作?
这是我的 Docker compose/stack 文件。当我在单个节点上部署时,一切正常,但当我在多个节点上部署时,出现以下错误:
绑定类型的挂载配置无效 绑定源路径不存在
version: '3'
services:
shinyproxy:
build: /etc/shinyproxy
deploy:
replicas: 3
user: root:root
hostname: shinyproxy
image: shinyproxy-example
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 5000:5000
networks:
- proxynetwork
mysql:
image: mysql
deploy:
replicas: 3
volumes:
- /mysqldata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: keycloak
MYSQL_USER: keycloak
MYSQL_PASSWORD: password
networks:
- proxynetwork
keycloak:
deploy:
replicas: 3
image: jboss/keycloak
volumes:
- /etc/letsencrypt/live/ds-gym.de/fullchain.pem:/etc/x509/https/tls.crt
- /etc/letsencrypt/live/ds-gym.de/privkey.pem:/etc/x509/https/tls.key
#- /theme/govuk-social-providers/:/opt/jboss/keycloak/themes/govuk-social-providers/
environment:
- PROXY_ADDRESS_FORWARDING=true
- KEYCLOAK_USER=myadmin
- KEYCLOAK_PASSWORD=mypassword
ports:
- 8443:8443
networks:
- proxynetwork
networks: …Run Code Online (Sandbox Code Playgroud) 我对从 API 获得的数据进行了大量处理:
这是数据返回的方式,数组的数量不同。
const objData = {
arr1: [1,2,3],
arr2: [1,2,1],
arr3: [2,1,2],
arr4: ["a","b", "c"]
}
Run Code Online (Sandbox Code Playgroud)
这是它应该看起来的样子
const desired = [
{a: 1, b: 1, c: 2, d: "a"},
{a: 2, b: 2, c: 1, d: "b"},
{a: 2, b: 1, c: 2, d: "c"}
]
Run Code Online (Sandbox Code Playgroud)
这给了我想要的结果,但它不是动态的,因为我必须提供数组的名称,并且不允许更改对象中的数组数量。
const DataObj = []
for (let i = 0; i < objData.arr1.length; i++) {
const objX = {
a: objData.arr1[i],
b: objData.arr2[i],
c: objData.arr3[i],
d: objData.arr4[i],
}
DataObj.push(objX)
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?如何使其独立于数组的名称和数据集中的数组数量?
我对 Docker-Compose 有以下设置:
version: '2'
services:
redis-sentinel:
image: docker.io/bitnami/redis-sentinel:6.2
volumes:
- redis-sentinel_data:/bitnami
redis:
image: docker.io/bitnami/redis:6.2
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- redis_data:/bitnami
volumes:
redis-sentinel_data:
driver: local
redis_data:
driver: local
Run Code Online (Sandbox Code Playgroud)
我的主人的名字应该是mymaster:
(base)>docker exec redis_redis-sentinel_1 redis-cli -p 26379 sentinel get-master-addr-by-name mymaster
192.168.80.3
6379
Run Code Online (Sandbox Code Playgroud)
我尝试通过 Python 连接:
from redis.sentinel import Sentinel
sentinel = Sentinel([("localhost", 26379)], socket_timeout=0.5)
r = sentinel.master_for("mymaster")
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误。
redis.sentinel.MasterNotFoundError: No master found for 'mymaster'
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
我必须编写一个 shell 脚本来初始化 docker swarm。
我需要将自己的 IP 地址作为参数传递:
sudo docker swarm init --advertise-addr 167.172.176.134
Run Code Online (Sandbox Code Playgroud)
我怎样才能动态地做到这一点?我知道该ifconfig命令,它允许我查看 IP,但我无法将整个内容作为变量传递。它应该是这样的
ip = ifconfig["IP"]
sudo docker swarm init --advertise-addr $ip
Run Code Online (Sandbox Code Playgroud) 我有以下功能:
output_names = [output.name for output in session.get_outputs()]
Run Code Online (Sandbox Code Playgroud)
session.get_outputs()可以返回我想从中获取名称属性的多个对象。如果列表的长度为1,我希望output_names是一个值,而不是一个只有单个值的列表。
output_names = [output.name for output in session.get_outputs()]
if len(output_names) == 1:
output_names = output_names[0]
Run Code Online (Sandbox Code Playgroud)
我可以这样做,但这感觉像是代码味道。有没有更优雅的方法来解决这个问题?
我使用非常基本的配置创建了一个简单的 VueJS 应用程序。我使用 webpack 配置来做到这一点。
\n\nvue init webpack app\nRun Code Online (Sandbox Code Playgroud)\n\n我构建这个简单的Dockerfile
FROM node:lts-alpine\n\n# install simple http server for serving static content\nRUN npm install -g http-server\n\n# make the \'app\' folder the current working directory\nWORKDIR /app\n\n# copy both \'package.json\' and \'package-lock.json\' (if available)\nCOPY package*.json ./\n\n# install project dependencies\nRUN npm install\n\n# copy project files and folders to the current working directory (i.e. \'app\' folder)\nCOPY . .\n\n# build app for production with minification\nRUN npm run build\n\nEXPOSE 3838\nCMD [ "http-server", "dist" ]\n …Run Code Online (Sandbox Code Playgroud) I thought in Python I am allowed to perform method chaining.
basket = [1,3,2,4,6,8]
basket.append(7)
basket.sort()
basket.reverse()
Run Code Online (Sandbox Code Playgroud)
This works.
basket.append(7).sort().reverse()
Run Code Online (Sandbox Code Playgroud)
This does not.
AttributeError: 'NoneType' object has no attribute 'sort'
Run Code Online (Sandbox Code Playgroud)
I am not sure what is going on here, but I assume that happens because in place methods result in "NoneType" result = basket.sort() and therefore the second method will be performed on the result and not the original object.
Can anyone help me how to do these operations without …
python ×5
vue.js ×3
list ×2
arrays ×1
bash ×1
deployment ×1
docker ×1
docker-stack ×1
docker-swarm ×1
fastapi ×1
firebase ×1
get ×1
javascript ×1
linux ×1
methods ×1
object ×1
pydantic ×1
python-3.10 ×1
python-3.x ×1
redis ×1
shell ×1
transition ×1