pyodbc

Python list of ints in prepared sql statement

妖精的绣舞 提交于 2019-12-30 22:52:34
问题 My question is somewhat the same as Python list of String to SQL IN parameter but I have a list of integers. The python code I use is: ids = [1000032, 1000048] sql = 'SELECT CompNo, CompName, CompType FROM Component WHERE DeptID IN (?)' cursor.execute(sql, [','.join(ids)]) And the Sybase database engine responds with: pyodbc.Error: ('07006', "[07006] [Sybase][ODBC Driver][SQL Anywhere]Cannot convert '1000032','1000048' to a numeric (-157) (SQLExecDirectW)") What is the correct way to do this?

Python list of ints in prepared sql statement

喜欢而已 提交于 2019-12-30 22:52:17
问题 My question is somewhat the same as Python list of String to SQL IN parameter but I have a list of integers. The python code I use is: ids = [1000032, 1000048] sql = 'SELECT CompNo, CompName, CompType FROM Component WHERE DeptID IN (?)' cursor.execute(sql, [','.join(ids)]) And the Sybase database engine responds with: pyodbc.Error: ('07006', "[07006] [Sybase][ODBC Driver][SQL Anywhere]Cannot convert '1000032','1000048' to a numeric (-157) (SQLExecDirectW)") What is the correct way to do this?

Passing Parameters to Stored Procedures using PyODBC

巧了我就是萌 提交于 2019-12-30 11:22:09
问题 I'm using pyODBC to connect to a SQL Server 2005 express database. I've created a stored procedure in SQLServer express that takes 2 string parameters e.g stored_proc(inpu1, input2) these parameters are of type datetime. I have tested the stored proc using management studio and it does return an appropriate result. However when i try to call the stored procedure from python(i'm using Eclipse) I get the error. pyodbc.DataError: ('22018', '[22018] [Microsoft][SQL Native Client]Invalid character

Querying MSSQL server 2012 from a Raspberry Pi 3 using Python, FreeTDS and pyodbc

限于喜欢 提交于 2019-12-30 10:52:53
问题 I am trying to query MSSQL server 2012 using Python as my scripting language on a raspberry Pi3. I have the need to create an application that will query MSSQL server and return some values that need to be displayed on a H.M.I. I chose the Raspberry Pi platform to develop this solution using Python as the programming language. I created the script using PyCharm on a Windows 7 PC and all worked well. When I moved it to the Raspberry Platform it didn't work. I am using pyODBC to do the

Python is slow when iterating over a large list

一个人想着一个人 提交于 2019-12-30 08:16:10
问题 I am currently selecting a large list of rows from a database using pyodbc. The result is then copied to a large list, and then i am trying to iterate over the list. Before I abandon python, and try to create this in C#, I wanted to know if there was something I was doing wrong. clientItems.execute("Select ids from largetable where year =?", year); allIDRows = clientItemsCursor.fetchall() #takes maybe 8 seconds. for clientItemrow in allIDRows: aID = str(clientItemRow[0]) # Do something with

Cannot Install Python Modules after Installing Anaconda

青春壹個敷衍的年華 提交于 2019-12-30 07:12:10
问题 [New Note: I cannot install through binstar or anaconda. Why can't I install in python, outside of anaconda? Is there a way to get my computer to stop using the anaconda install of python when I don't luanch it specifically through the continuum launcher?] I have an install of Python 2.7 on a windows machine. I just recently installed Anaconda, in addition. I just tried to install a new module for my Python install. I opened a command prompt in an unzipped folder for a python module and ran:

How to check version of python package if no __version__ variable is set

99封情书 提交于 2019-12-30 05:59:46
问题 I am using pyodbc and I want to know the version of it that I am using. Apparently I cannot use pyodbc.__version__ because probably the variable is not set. How else can I figure out the version of the package? 回答1: It does have the version info, just use .version : In [4]: pyodbc.version Out[4]: '3.0.10' The pip show command would also get it for you: In [54]: pip.main(["show","pyodbc"]) --- Metadata-Version: 1.1 Name: pyodbc Version: 3.0.10 Summary: DB API Module for ODBC Home-page: http:/

Using SQL Alchemy and pyodbc with IronPython 2.6.1

元气小坏坏 提交于 2019-12-30 05:27:06
问题 I'm using IronPython and the clr module to retrieve SQL Server information via SMO. I'd like to retrieve/store this data in a SQL Server database using SQL Alchemy, but am having some trouble loading the pyodbc module. Here's the setup: IronPython 2.6.1 (installed at D:\Program Files\IronPython) CPython 2.6.5 (installed at D:\Python26) SQL Alchemy 0.6.1 (installed at D:\Python26\Lib\site-packages\sqlalchemy) pyodbc 2.1.7 (installed at D:\Python26\Lib\site-packages) I have these entries in the

Passing a list of values from Python to the IN clause of an SQL query

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 08:13:27
问题 I am trying to pass a list like below to a sql query x = ['1000000000164774783','1000000000253252111'] I am using sqlalchemy and pyodbc to connect to sql: import pandas as pd from pandas import Series,DataFrame import pyodbc import sqlalchemy cnx=sqlalchemy.create_engine("mssql+pyodbc://Omnius:MainBrain1@172.31.163.135:1433/Basis?driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0") I tried using various string format functions to be used in the sql query. below is one of them xx =

Syntax for a parameter query in Python (pyodbc)

◇◆丶佛笑我妖孽 提交于 2019-12-29 02:15:22
问题 I am trying to write results of some processing into SQL Server table. My results are store in a list of lists where each item of the list is a list. I am using parameters (6 params) and I am getting the following error: cnxn.execute(sqlStatement, (item[0],item[1],item[2],item[3],item[4],item[5])) pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 6 parameters were supplied', 'HY000') That's my code sqlStatement = "INSERT INTO CEA_CR (`SessionID`, `Session.Call_TYPE_Assigned