[Python] pyodbc 'The SQL contains 1 parameter markers, but 2 parameters were supplied'

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    Here's my code:

    tmp = '''SELECT JSON_QUERY(formdata, '$."?-container"') from Disclosures where disclosureid = ?'''
    print(tmp)
    print ([itemType, disclosureID])
    db.execute(tmp, itemType, disclosureID)
    return db.fetchone()[0]

    SELECT JSON_QUERY(formdata, '$."?-container"') from Disclosures where disclosureid = ?
    ['gift', 1]


    Here's the error message;


    pyodbc.ProgrammingError: ('The SQL contains 1 parameter markers, but 2 parameters were supplied', 'HY000')
    ​

    What am I doing wrong? Nothing I have tried thus far has rectified the Python error message.

    Table DDL:

    CREATE TABLE [dbo].[Disclosures](
    [disclosureid] [int] IDENTITY(1,1) NOT NULL,
    [orgid] [int] NOT NULL,
    [userid] [int] NOT NULL,
    [formdata] [nvarchar](max) NOT NULL,
    [retain] [bit] NULL,
    [reportsassigned] [bit] NULL,
    CONSTRAINT [PK__Disclosu__F6B145D3D95E8196] PRIMARY KEY CLUSTERED ( [disclosureid] ASC)
    );

    Continue reading...

Compartilhe esta Página