我在迁移时遇到了这个错误。有什么办法可以在我的数据库中保存数据。我知道删除 auth_user 表可以解决这个问题。我正在运行 postgresql。谢谢!
FATAL ERROR - The following SQL query failed: ALTER TABLE "api_poi" ADD CONSTRAINT "user_id_refs_id_20f256ff" FOREIGN KEY ("user_id") REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED;
The error was: insert or update on table "api_poi" violates foreign key constraint "user_id_refs_id_20f256ff"
DETAIL: Key (user_id)=(1) is not present in table "auth_user".
Run Code Online (Sandbox Code Playgroud) 我正在使用 async io 对两种执行方法进行计时
情况1:
async def test():
print(f"started at {time.strftime('%X')}")
await asyncio.create_task(say_after(2, 'hello'))
await asyncio.create_task(say_after(4, 'world'))
print(f"finished at {time.strftime('%X')}")
Run Code Online (Sandbox Code Playgroud)
它的回应是:
started at 12:31:05
hello
world
finished at 12:31:11
Run Code Online (Sandbox Code Playgroud)
总共6秒
案例2:
async def test():
print(f"started at {time.strftime('%X')}")
t1=asyncio.create_task(say_after(2, 'hello'))
t2= asyncio.create_task(say_after(4, 'world'))
await t1
await t2
print(f"finished at {time.strftime('%X')}")
Run Code Online (Sandbox Code Playgroud)
它的回应是:
started at 12:31:05
hello
world
finished at 12:31:09
Run Code Online (Sandbox Code Playgroud)
总共4秒
为什么会这样呢?
如果我想执行以下操作:
a := "%shello%s"
b:= fmt.Sprintf("%sWorld",a)
fmt.Printf(b)
Run Code Online (Sandbox Code Playgroud)
我要列印
%shello%sWorld
Run Code Online (Sandbox Code Playgroud)
即%s仅在%sWorld中被替换。
我怎样才能做到这一点?
我不想用替换 %%shello%%s