MagicStack / MagicStack/asyncpg

"Cannot insert multiple commands into prepared statement" issue while executing query with params

未關閉
#30 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

question
主要語言
Python
星號
8.1k
分支
468
PR 合併指標
30 天內沒有已合併 PR

描述

(python 3.5.1, asyncpg 0.5.4)

Consider the next code

import asyncpg
import asyncio

async def run():
    con = await asyncpg.connect(user="coldmind", database="test")
    await con.execute('SELECT ($1); SELECT 2;', 1)
asyncio.get_event_loop().run_until_complete(run())

The executing fails with asyncpg.exceptions.PostgresSyntaxError: cannot insert multiple commands into a prepared statement error, while the another example (without passing params to the query) works well with multiple commands:

import asyncpg
import asyncio


async def run():
    con = await asyncpg.connect(user="coldmind", database="test")
    await con.execute('SELECT 1; SELECT 2;')
asyncio.get_event_loop().run_until_complete(run())

Why is the first example using a prepared statement instead of executing it?

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 con.execute 進入點開始,執行 issue 中的兩個 Python 範例,以比較參數化查詢和非參數化查詢。追蹤參數如何影響執行,然後確立多個命令的預期行為,並記錄或測試由此得出的決定。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
postgresql, python
領域
databases
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。