pyodbc

Iterating over PyoDBC result without fetchall()

谁都会走 提交于 2019-12-03 14:48:39
I'm trying to process a very large query with pyodbc and I need to iterate over the rows without loading them all at once with fetchall(). Is there a good and principled way to do this? Sure - use a while loop with fetchone . http://code.google.com/p/pyodbc/wiki/Cursor#fetchone row = cursor.fetchone() while row is not None: # do something row = cursor.fetchone() you could also use cursor.fetchmany() if you want to batch up the fetches (defaults to 1 if you don't override it) http://code.google.com/p/pyodbc/wiki/Cursor#fetchmany 来源: https://stackoverflow.com/questions/17707264/iterating-over

Pyodbc installation error on Ubuntu 16.04 with Sql Server installed

与世无争的帅哥 提交于 2019-12-03 14:08:54
问题 I am trying to test my scripts for data migration from mssql-server to oracle server . For this, I have to install pyodbc python package for Ubuntu , it has the dependency of unixodbc . When I try to install unixodbc-dev using: sudo apt-get install unixodbc-dev It gives broken packages error : The following packages have unmet dependencies: unixodbc-dev : Depends: unixodbc (= 2.3.1-4.1) Depends: odbcinst1debian2 (= 2.3.1-4.1) but it is not going to be installed E: Unable to correct problems,

How to use windows authentication to connect to MS SQL server from windows workstation in another domain with Python

独自空忆成欢 提交于 2019-12-03 13:33:36
I'm trying to connect to SQL server 2000 installed on Windows server 2003 from Windows Server 2008 R2 using Python 3.4 and pyodbc module. Those servers are in different AD domains. Windows only authentication is enabled on SQL server and I can't change that. drv = '{SQL server}' svr = 'sql.my-domain.local' usr = 'my-domain.local\testuser' pwd = 'password' db = 'testdb' pyodbc.connect(driver=drv, server=svr, user=usr, password=pwd, database=db) The connection above fails with the following error: pyodbc.Error: ('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQLServer] Login failed for

Connecting to MS SQL Server using python on linux with 'Windows Credentials'

只愿长相守 提交于 2019-12-03 13:06:08
问题 Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials? I can connect perfectly fine from my windows machine using Windows Credentials, but attempting to do the same from a linux python with pyodbs + freetds + unixodbc >>import pyodbc >>conn = pyodbc.connect("DRIVER={FreeTDS};SERVER=servername;UID=username;PWD=password;DATABASE=dbname") results in this error: class 'pyodbc.Error'>: ('28000', '[28000] [unixODBC][FreeTDS][SQL Server]Login

pyodbc.connect() works, but not sqlalchemy.create_engine().connect()

拥有回忆 提交于 2019-12-03 11:43:42
I am attempting to write a Python script that can take Excel sheets and import them into my SQL Server Express (with Windows Authentication) database as tables. To do this, I am using pandas to read the Excel files into a pandas DataFrame , I then hope to use pandas.to_sql() to import the data into my database. To use this function, however, I need to use sqlalchemy.create_engine() . I am able to connect to my database using pyodbc alone, and run test queries. This conection is done with the followng code: def create_connection(server_name, database_name): config = dict(server=server_name,

Building a connection URL for mssql+pyodbc with sqlalchemy.engine.url.URL

回眸只為那壹抹淺笑 提交于 2019-12-03 10:14:52
问题 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... credentials = { 'username' : 'SPOTTER_xyz_ACC', 'password' : '123Goodbye2016!@#', 'host' : 'MARYLQLT01', 'database' : 'LRS_DUS', 'port' : '1560'} connect_url = sqlalchemy.engine.url.URL( 'mssql+pyodbc', username=credentials['username'], password=credentials['password'], host=credentials['host'], port=credentials['port'], query=dict

Unable to connect pyODBC with SQL Server 2008 Express R2

我怕爱的太早我们不能终老 提交于 2019-12-03 09:11:45
I am using following code to connect with SQL 2008 R2: cnxnStoneedge = pyodbc.connect("DRIVER={SQL Server};SERVER=127.0.0.1;DATABASE=myDB;UID=admin;PWD=admin") Which gives error: Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect)') args = ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNE...t exist or access denied. (17) (SQLDriverConnect)') with_traceback = <built-in method with_traceback of Error object> I am not sure whether SQL connecting via named Pipes or TCP, I did enable IP Address.

pyodbc and python 3.4 on Windows

一个人想着一个人 提交于 2019-12-03 08:42:51
问题 pyodbc is a very nice thing, but the Windows installers only work with their very specific python version. With the release of Python 3.4, the only available installers just stop once they don't see 3.3 in the registry (though 3.4 is certainly there). Copying the .pyd and .egg-info files from a 3.3 installation into the 3.4 site-packages directory doesn't seem to do the trick. When importing pyodbc, an ImportError is thrown: ImportError: DLL load failed: %1 is not a valid Win32 application.

Building a connection URL for mssql+pyodbc with sqlalchemy.engine.url.URL

狂风中的少年 提交于 2019-12-03 00:44:46
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... credentials = { 'username' : 'SPOTTER_xyz_ACC', 'password' : '123Goodbye2016!@#', 'host' : 'MARYLQLT01', 'database' : 'LRS_DUS', 'port' : '1560'} connect_url = sqlalchemy.engine.url.URL( 'mssql+pyodbc', username=credentials['username'], password=credentials['password'], host=credentials['host'], port=credentials['port'], query=dict(service_name=credentials['database'])) engine = create_engine(connect_url) connection=engine.connect()

pyodbc and python 3.4 on Windows

柔情痞子 提交于 2019-12-02 22:33:25
pyodbc is a very nice thing, but the Windows installers only work with their very specific python version. With the release of Python 3.4, the only available installers just stop once they don't see 3.3 in the registry (though 3.4 is certainly there). Copying the .pyd and .egg-info files from a 3.3 installation into the 3.4 site-packages directory doesn't seem to do the trick. When importing pyodbc, an ImportError is thrown: ImportError: DLL load failed: %1 is not a valid Win32 application. Is there a secret sauce that can be added to make the 3.3 file work correctly? Or do we just need to