pyodbc

Authenticate from Linux to Windows SQL Server with pyodbc

笑着哭i 提交于 2020-03-17 10:55:05
问题 I am trying to connect from a linux machine to a windows SQL Server with pyodbc. I do have a couple of constraints: Need to log on with a windows domain account Need to use python3 Need to do it from Linux to Windows Need to connect to a specific instance I set up the environment as described by microsoft and have it working (I can import pyodbc and use the configured mussel driver). I am not familiar with Windows domain authentication and what not, so there is where my problem is. My

How to connect to Azure sql database with python SQL alchemy using Active directory integrated authentication

六眼飞鱼酱① 提交于 2020-02-05 13:15:27
问题 I am trying to connect to an Azure SQL Database using SQL Alchemy in python. The database was recently moved to Azure from on-prem and as I understand that azure does not support Windows Auth. I can connect to the DB from SSMS using Active Directory Integrated Auth. When the Db was on prem i would use the following connection string and it worked: "mssql+pyodbc://@*Server*/*DB*?driver=SQL Server" I have tried a few other connection string and cannot get it to work. "mssql+pyodbc://@*Server*/

passing a date to a function in python that is calling sql server [duplicate]

廉价感情. 提交于 2020-02-04 04:15:51
问题 This question already has an answer here : Pandas read_sql with parameters (1 answer) Closed 3 years ago . I am trying to pass date1 and date 2 to a function in python that creates a dataframe from a sql server import datetime as dt import pandas as pd import pyodbc import sqlalchemy from pandas import Series,DataFrame 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") def func1(date1,date2):

Insert pandas dataframe created within Python into SQL Server

泄露秘密 提交于 2020-02-02 09:13:05
问题 As referenced, I've created a collection of data (40k rows, 5 columns) within Python that I'd like to insert back into a SQL Server table. Typically, within SQL I'd make a 'select * into myTable from dataTable' call to do the insert, but the data sitting within a pandas dataframe obviously complicates this. I'm not formally opposed to using SQLAlchemy (though would prefer to avoid another download and install), but would prefer to do this natively within Python, and am connecting to SSMS

Pulling MS access tables and putting them in data frames in python

可紊 提交于 2020-02-01 04:16:48
问题 I have tried many different things to pull the data from Access and put it into a neat data frame. right now my code looks like this. from pandas import DataFrame import numpy as np import pyodbc from sqlalchemy import create_engine db_file = r'C:\Users\username\file.accdb' user = 'user' password = 'pw' odbc_conn_str = 'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s;UID=%s;PWD=%s' % (db_file, user, password) conn = pyodbc.connect(odbc_conn_str) cur = conn.cursor() qry = cur.execute(

pyodbc ImportError: DLL load failed: The specified module could > not be found

…衆ロ難τιáo~ 提交于 2020-01-30 08:12:25
问题 When trying to import pyodbc i get the below error. How do I resolve this? All other things I have found on here has not worked. I have also tried everything on this site: https://medium.com/@mauridb/how-to-check-your-anaconda-version-c092400c9978 when it comes to updating the anaconda version (which has only been installed for 30 days on this computer). I have also tried the below code, and I still get the same error on import. Any assistance would be great. pip install pyodbc --force

pyodbc ImportError: DLL load failed: The specified module could > not be found

不想你离开。 提交于 2020-01-30 08:12:20
问题 When trying to import pyodbc i get the below error. How do I resolve this? All other things I have found on here has not worked. I have also tried everything on this site: https://medium.com/@mauridb/how-to-check-your-anaconda-version-c092400c9978 when it comes to updating the anaconda version (which has only been installed for 30 days on this computer). I have also tried the below code, and I still get the same error on import. Any assistance would be great. pip install pyodbc --force

How to install PYODBC in Databricks

限于喜欢 提交于 2020-01-28 12:31:31
问题 I have to install pyodbc module in Databricks. I have tried using this command ( pip install pyodbc ) but it is failed due to below error. Error message 回答1: I had some problems a while back with connecting using pyobdc, details of my fix are here: https://datathirst.net/blog/2018/10/12/executing-sql-server-stored-procedures-on-databricks-pyspark I think the problem stems from PYTHONPATH on the databricks clusters being set to the Python 2 install. I suspect the lines: %sh apt-get -y install

DB2 connection through pyodbc and pandas.io.sql in Unix Box with non-root

落爺英雄遲暮 提交于 2020-01-25 04:38:07
问题 I am trying to connect to IBM DB2 through python using pyodbc and pandas.io.sql, now the twist is I am not Super User or better to say I dont have any right to install DB2 Driver or anything else. Is it possible to use pyodbc and pandas.io.sql to connect to DB2 with such conditions. The code which I used so far is cnxn = pyodbc.connect('Driver={FreeTDS}; Hostname=eee;Port=25369;Protocol=TCPIP;Database=rt;CurrentSchema=abc;UID=abc;PWD=efg;') Error pyodbc.Error: ('IM002', '[IM002] [unixODBC]

Prevent Django from updating identity column in MSSQL

怎甘沉沦 提交于 2020-01-24 06:45:10
问题 I'm working with a legacy DB in MSSQL. We have a table that has two columns that are causing me problems: class Emp(models.Model): empid = models.IntegerField(_("Unique ID"), unique=True, db_column=u'EMPID') ssn = models.CharField(_("Social security number"), max_length=10, primary_key=True, db_column=u'SSN') # Field name made lowercase. So the table has the ssn column as primary key and the relevant part of the SQL-update code generated by django is this: UPDATE [EMP] SET [EMPID] = 399, ....