Skip to content

ProgrammingError: positional and named binds cannot be intermixed #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlineGobbi opened this issue Mar 18, 2024 · 2 comments
Closed
Labels

Comments

@AlineGobbi
Copy link

AlineGobbi commented Mar 18, 2024

cx_Oracle.version: 8.3.0
cx_Oracle.clientversion: (11, 2, 0, 1, 0)
platform.platform: Windows-10-10.0.22631-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.11.5

import numpy as np
import cx_Oracle
import pandas as pd

Captura de tela 2024-03-18 090948

but, I need to create a table in the DW and use these results. I have already make this on another projects, and it worked, but for this, don't work.

I create the table ( check on pl/sql and is there) but when i insert gives error

# Criar tabela DM_IC_NPS no banco de dados Oracle
create_table_query = '''
CREATE TABLE DM_IC_NPS (
    Ano NUMBER,
    Janeiro VARCHAR2(30),
    Fevereiro VARCHAR2(30),
    Março VARCHAR2(30),
    Abril VARCHAR2(30),
    Maio VARCHAR2(30),
    Junho VARCHAR2(30),
    Julho VARCHAR2(30),
    Agosto VARCHAR2(30),
    Setembro VARCHAR2(30),
    Outubro VARCHAR2(30),
    Novembro VARCHAR2(30),
    Dezembro VARCHAR2(30),
    Empresa VARCHAR2(30)
)
'''

cursor.execute(create_table_query)

# Inserir dados na tabela DM_IC_NPS
# cursor e commit devem ficar dentro da função!!!!!
for index, row in DM_IC_NPS.iterrows():
    insert_query = '''
    INSERT INTO DM_IC_NPS VALUES (
        :1, :2, :3, :4, :5, :6, :7, :8, :9, :10,
        :11, :12, :13, :14, :15
    )
    '''
    cursor.execute(insert_query, tuple(row))
    # Commit para salvar as alterações
    conn.commit()

THE ERROR:


ProgrammingError Traceback (most recent call last)
Cell In[47], line 10
3 for index, row in DM_IC_NPS.iterrows():
4 insert_query = '''
5 INSERT INTO DM_IC_NPS VALUES (
6 :1, :2, :3, :4, :5, :6, :7, :8, :9, :10,
7 :11, :12, :13, :14
8 )
9 '''
---> 10 cursor.execute(insert_query, tuple(row))
11 # Commit para salvar as alterações
12 conn.commit()

ProgrammingError: positional and named binds cannot be intermixed

@AlineGobbi AlineGobbi added the bug label Mar 18, 2024
@AlineGobbi
Copy link
Author

i make fillna(0) and it worked out

@anthony-tuininga
Copy link
Member

Not sure what you did but glad you figured it out! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants