I have a dataframe df and I want to to execute a query to insert into a table all the values from the dataframe. Basically I am trying to load as the following query: For that I have the following code: However, I am getting the following error: Does anyone know what I am doing wrong? Answer See below my
Tag: pyodbc
Why does SQL Server return numbers like 0.759999 while MySQL returns 0.76?
I have a SQL Server database table which has three columns. As an example, one of the values in this column might be 0.76. This column of data, named ‘paramvalue’ is defined as real. When I use the pyodbc module command fetchall() I get back a number like 0.7599999904632568 instead of 0.76. I’m using Visual Studio 2017 and Python Tools
Multithreaded pyodbc connection
I am trying to use a pyodbc connection in multiple threads. I am receieving the following error: Connection is busy with results for another command (0) (SQLExecDirectW)’). I also tried setting MultipleActiveResultSets=yes; and got the same results. I really don’t want to have to create a connection for every thread or query. I also don’t want to use a lock
Specifying pyODBC options (fast_executemany = True in particular) using SQLAlchemy
I would like to switch on the fast_executemany option for the pyODBC driver while using SQLAlchemy to insert rows to a table. By default it is of and the code runs really slow… Could anyone suggest how to do this? Edits: I am using pyODBC 4.0.21 and SQLAlchemy 1.1.13 and a simplified sample of the code I am using are
Building a connection URL for mssql+pyodbc with sqlalchemy.engine.url.URL
The problem… I am trying to connect to a MSSql server via SQLAlchemy. Here is my code with fake credentials (not my real credentials obviously). The code… And this is the .pyodbc error that I am getting. Additional Details But, here is what is weird… I if make a pyodbc connection and use Pandas.read_sql, then I can get data without
Can’t open lib ‘ODBC Driver 13 for SQL Server’? Sym linking issue?
When I try to connect to a sql server database with pyodbc (on mac): I get the following error: Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘ODBC Driver 13 for SQL Server’ : file not found (0) (SQLDriverConnect)”) When I path in the actual driver location: It starts working! My odbcinst.ini looks like this: How can I get my reference
Python – Using pyodbc to connect to remote server using info from Excel data connection
I have an excel (albeit, one that’s on our company server) that has a data connection to our SQL database so we can make nice pivot tables. I would like to get that data into python (on my local computer) so I can do some faster analysis. I have installed pyodbc. Here is the “connection string” from the excel: and
Function sequence error in PYODBC
I am using pyodbc to connect to a database and extract certain data from it. Here is my code: And I got following error after I run above code: pyodbc.Error: (‘HY010’, ‘[HY010] [Microsoft][ODBC SQL Server Driver]Function sequence error (0) (SQLFetch)’) May I know what caused such problem, and how can I fix it? Thanks. Answer I believe your problem is
Output pyodbc cursor results as python dictionary
How do I serialize pyodbc cursor output (from .fetchone, .fetchmany or .fetchall) as a Python dictionary? I’m using bottlepy and need to return dict so it can return it as JSON. Answer If you don’t know columns ahead of time, use Cursor.description to build a list of column names and zip with each row to produce a list of dictionaries.
Retrieving Data from SQL Using pyodbc
I am trying to retrieve data from an SQL server using pyodbc and print it in a table using Python. However, I can only seem to retrieve the column name and the data type and stuff like that, not the actual data values in each row of the column. Basically I am trying to replicate an Excel sheet that retrieves