pyodbc

How to get entire VARCHAR(MAX) column with Python pypyodbc

自闭症网瘾萝莉.ら 提交于 2019-12-28 18:12:22
问题 I have a Python program that connects to an MSSQL database using an ODBC connection. The Python library I'm using is pypyodbc. Here is my setup: Windows 8.1 x64 SQL Server 2014 x64 Python 2.7.9150 PyPyODBC 1.3.3 ODBC Driver: SQL Server Native Client 11.0 The problem I'm having is that when I query a table with a varchar(max) column, the content is being truncated. I'm new to pypyodbc and I've been searching around like crazy and can't find anything on how to prevent this from happening in

How to get entire VARCHAR(MAX) column with Python pypyodbc

夙愿已清 提交于 2019-12-28 18:12:07
问题 I have a Python program that connects to an MSSQL database using an ODBC connection. The Python library I'm using is pypyodbc. Here is my setup: Windows 8.1 x64 SQL Server 2014 x64 Python 2.7.9150 PyPyODBC 1.3.3 ODBC Driver: SQL Server Native Client 11.0 The problem I'm having is that when I query a table with a varchar(max) column, the content is being truncated. I'm new to pypyodbc and I've been searching around like crazy and can't find anything on how to prevent this from happening in

Pyodbc error Data source name not found and no default driver specified paradox

笑着哭i 提交于 2019-12-28 11:52:54
问题 I am attempting to use pyobdc to read data from a paradox database, and I keep getting the following error when attempting to connect to the database: pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)') I have tried to create new DNS links for the database but it has not helped what so ever. My system links are as follows: My code is: import os import sys import time import pyodbc LOCATION = "c:

Returning primary key on INSERT with pyodbc

▼魔方 西西 提交于 2019-12-25 08:49:45
问题 I have a program inserting a bunch of data into an SQL database. The data consists of Reports , each having a number of Tags . A Tag has a field report_id , which is a reference to the primary key of the relevant Report . Now, each time I insert the data, there can be 200 Reports or even more, each maybe having 400 Tags . So in pseudo-code I'm now doing this: for report in reports: cursor_report = sql('INSERT report...') cursor_report.commit() report_id = sql('SELECT @@IDENTITY') for tag in

In Python, display output of SQL query as a table, just like it does in SQL

心已入冬 提交于 2019-12-25 03:15:36
问题 this seems like a basic function, but I'm new to Python so maybe I'm not googling this correctly. In Microsoft SQL Server, when you have a statement like SELECT top 100 * FROM dbo.Patient_eligibility you get a result like Patient_ID | Patient_Name | Patient_Eligibility 67456 | Smith, John | Eligible ... etc. Etc. I am running a connection to SQL through Python as such, and would like the output to look exactly the same as in SQL. Specifically - with column names and all the data rows

Connect to SQL Server Analysis Service from Python

馋奶兔 提交于 2019-12-25 02:26:05
问题 I'm using PyODBC for SQL Server 2008 database engine and it works well. I can retrieve records and execute procedures and views with no problem. My issue is I can't connect to SQL Server 2008 Analysis Server using PyODBC. Following list shows what I've tried: cnxn = pyodbc.connect(r'Driver={SQL Server};Server=127.0.0.1;Database=DB1;Trusted_Connection=yes;') And cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=DB1;Trusted_Connection=yes;UID=TB\\user;PWD=123123') What's the

How do I encode Unicode strings using pyodbc to save to a SAS dataset?

我与影子孤独终老i 提交于 2019-12-25 01:42:44
问题 I'm using Python to read and write SAS datasets, using pyodbc and the SAS ODBC drivers. I can load the data perfectly well, but when I save the data, using something like: cursor.execute('insert into dataset.test VALUES (?)', u'testing') ... I get a pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC Driver Manager] SQL data type out of range (0) (SQLBindParameter)') error. The problem seems to be the fact I'm passing a unicode string; what do I need to do to handle this? 回答1: Do you know what

Unable to install pyodbc

寵の児 提交于 2019-12-25 01:21:44
问题 I am using python 3.3.0 .. Within this package C:\Python34\Scripts is my pip and I have added this path to my system and user environment variable PATH the link to this pip folder,I have installed Visual C++ 2010 but i don't know what needs to be done once it is installed if or not i need to configure something, yet when I do : C:\Python33\Scripts>pip install https://pyodbc.googlecode.com/files/pyodbc-3.0.7.zip It gives me the following error: This is what stackoverflow editor has changed it

How can I insert a list returned from pyodbc mssql query into mysql through stored procedure using pymysql

左心房为你撑大大i 提交于 2019-12-25 00:12:51
问题 I am pulling data from a MSSQL db using pyodbc which returns my data set in a list. This data then needs to be transferred into a MySQL db. I have written the following stored procedure in MySQL. CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_int_pmt`( IN pmtamt DECIMAL(16,10), IN pmtdt DATETIME, IN propmtref VARCHAR(128), IN rtdinv_id INT(11) ) BEGIN INSERT INTO ay_financials.payment ( pmtamt, pmtdt, propmtref, rtdinv_id ) VALUES ( pmtamt, pmtdt, propmtref, rtdinv_id ); END The procedure

Custom Django binary field & SQL Server 2008

允我心安 提交于 2019-12-24 20:33:02
问题 I have a little table: CREATE TABLE [organization_division] ( [id] int IDENTITY (1, 1) NOT NULL PRIMARY KEY, [uuid] binary(16) NOT NULL ) I can insert a record with SQL query: INSERT INTO [organization_division] ([uuid]) VALUES (0x244c71c6c9444f38b67ab1dcfbb5fc32) The Django model for this table is: from apps.lib.fields import GUIDField class Division(models.Model): uuid = GUIDField() GUIDField is my attempt to create a custom field: class GUIDField(models.Field): description = "GUID binary