Can someone explain why do I get an error when executing the following simple query with pandas: import pyodbc import pandas as pd connstr = ‘Driver={SQL Server}; Server=sr1; Database=db’ conn = …
Tag: pyodbc
Unable to use ‘read_sql’ to call a SQL query class
I am trying to pull results from the database with the following code: I get an error: I saw a similar question at TypeError: ‘pyodbc.Cursor’ object is not callable (Python 3.6) but unable to get an answer from there. Answer I got it to work by editing the class from into
Python SQL: Error reading and executing SQL file
I’m trying to red and execute a SQL file in Python using sqlalchemy. Should be simple, right? I get this error Why am I getting this error? I’m not sure if this is a file encoding error or a SQLAlchemy error. Ideally, this should be simple. EDIT: This code works fine, assuming the table temp exists: EDIT 2: For reference,
pyodbc.ProgrammingError: (‘The SQL contains 1 parameter markers, but 7 parameters were supplied’, ‘HY000’) [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 years ago. Improve this question When running the below script it ends in the following error, as I do find other posts on this error I am not finding the fix similar
How to retry after sql connection failed in python?
Whats the right way to retry when connection/write to a DB fails in python? Im trying to use this code and it works until i restart my sql server and python tries to connect to it i get “retry after …
Python SQL script inserts only the last row of the dataframe to SQL Server [pyodbc]
I am trying to import a pandas dataframe to Microsoft SQL Server. Even though, the command is correct and executed successfully, when I select the first 1000 rows of the table in SQL server only the …
Query table with compound primary keys
I’m using pyodbc to connect to a machine database, and query a number of tables in that database using pandas.read_sql(tbl,cnxn), where tbl = “SELECT * FROM TABLE”, cnxn is pyodbc.connect(‘DSN=DATASOURCE;UID=USERID;PWD=PASSWORD’). It works on most tables, but some tables return: DatabaseError: Execution failed on sql ‘SELECT * FROM TABLE’: (’42S02′, ‘[42S02] [Microsoft][ODBC driver for Oracle][Oracle]ORA-00942: table or view does not exist
pyodbc Incorrect syntax near ‘-‘. (102)
I am trying to select all data from table that contains “-” dash symbol, and i get error cursor.execute(qStr) pyodbc.ProgrammingError: (‘42000’, “[42000] [Microsoft][ODBC SQL Server Driver][SQL …
Remote connection to MS SQL – Error using pyodbc vs success using SQL Server Management Studio
I have a MS SQL database in the same network but in other computer. Using the SQL Server Management Studio (SSMS) Express, I can find the database and connect without problems. But when I use pyodbc to connect to the same server using: I get following error: OBS: I guess that the server string should be right, since if I
Python -SQL String Escape Wildcards
I tried to see if this question had been asked, which it probably has, but I couldn’t find an answer. I am querying MS SQL Server from a python script using pyodbc. I am defining a function to query …