pyodbc

pyodbc to sqlalchemy connection

心已入冬 提交于 2021-02-19 07:16:26
问题 I am trying to switch a pyodbc connection to sqlalchemy. The working pyodbc connection is: import pyodbc con = 'DRIVER={ODBC Driver 11 for SQL Server};SERVER=server.com\pro;DATABASE=DBase;Trusted_Connection=yes' cnxn = pyodbc.connect(con) cursor = cnxn.cursor() query = "Select * from table" cursor.execute(query) I tried: from sqlalchemy import create_engine dns = 'mssql+pyodbc://server.com\pro/DBase?driver=SQL+Server' engine = create_engine(dns) engine.execute('Select * from table').fetchall(

setting the location where pyodbc searches for odbcinst.ini file

馋奶兔 提交于 2021-02-19 02:36:26
问题 I am trying to query ODBC compliant databases using pyodbc in ubuntu . For that, i have installed the driver (say mysql-odbc-driver). After installation the odbcinst.ini file with the configurations gets created in the location /usr/share/libmyodbc/odbcinst.ini When i try to connect to the database using my pyodbc connection code, i get a driver not found error message . Now when I copy the contents of the file to /etc/odbcinst.ini , it works! This means pyodbc searches for the driver

Pyspark connection to the Microsoft SQL server?

大憨熊 提交于 2021-02-17 02:47:40
问题 I have a huge dataset in SQL server, I want to Connect the SQL server with python, then use pyspark to run the query. I've seen the JDBC driver but I don't find the way to do it, I did it with PYODBC but not with a spark. Any help would be appreciated. 回答1: Please use the following to connect to Microsoft SQL: def connect_to_sql( spark, jdbc_hostname, jdbc_port, database, data_table, username, password ): jdbc_url = "jdbc:sqlserver://{0}:{1}/{2}".format(jdbc_hostname, jdbc_port, database)

Pyspark connection to the Microsoft SQL server?

廉价感情. 提交于 2021-02-17 02:47:29
问题 I have a huge dataset in SQL server, I want to Connect the SQL server with python, then use pyspark to run the query. I've seen the JDBC driver but I don't find the way to do it, I did it with PYODBC but not with a spark. Any help would be appreciated. 回答1: Please use the following to connect to Microsoft SQL: def connect_to_sql( spark, jdbc_hostname, jdbc_port, database, data_table, username, password ): jdbc_url = "jdbc:sqlserver://{0}:{1}/{2}".format(jdbc_hostname, jdbc_port, database)

How to use executemany in pyodbc to run multiple SELECT queries

一个人想着一个人 提交于 2021-02-17 02:37:38
问题 Im using PYODBC to query an SQL DB multiple times based on the values of a pandas dataframe column (seen below as a list of values, since I used the ToList() function to turn the column into a list. #the connection string cnxn = pyodbc.connect(driver='{SQL Server}', server = 'NameOfTheServer',autocommit = True,uid ='name',pwd ='password') cursor = cnxn.cursor() params = ['3122145', '523532236'] sql = (""" SELECT SO.column FROM table AS SO WHERE SO.column = ? """) cursor.executemany(sql,

import text file to Access 2003 database using Python

故事扮演 提交于 2021-02-16 21:22:36
问题 I'm trying to import a pipe delimited text file into an access database with an existing table using a Python 3.4 application I'm working on, but I'm having some trouble. The application will be used to import different text files so I'm using an entry widget to write in the filename and I want the contents of the file entered to be loaded into my table. I tried loading the file into the able just using access and it worked fine so the formatting should be good. Below is some of the code I've

SQL Server queries beyond a certain character length are timing out

。_饼干妹妹 提交于 2021-02-11 16:33:44
问题 Recently I migrated an ETL platform from Python 2.7 to 3 and also updated its Docker image from Ubuntu 16.04 to 18.04. After the migration I started encountering some really strange behavior when trying to reflect SQL Server tables using SQLAlchemy with the pyodbc driver. Initially, I was seeing this error message: [08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLExecDirectW) I had updated SQLAlchemy from 0.9.8 to 1.3.10 (I hadn't touched pyodbc which was at 3.0.10) so I

SQL Server queries beyond a certain character length are timing out

谁说胖子不能爱 提交于 2021-02-11 16:31:51
问题 Recently I migrated an ETL platform from Python 2.7 to 3 and also updated its Docker image from Ubuntu 16.04 to 18.04. After the migration I started encountering some really strange behavior when trying to reflect SQL Server tables using SQLAlchemy with the pyodbc driver. Initially, I was seeing this error message: [08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLExecDirectW) I had updated SQLAlchemy from 0.9.8 to 1.3.10 (I hadn't touched pyodbc which was at 3.0.10) so I

SQL Server queries beyond a certain character length are timing out

送分小仙女□ 提交于 2021-02-11 16:31:31
问题 Recently I migrated an ETL platform from Python 2.7 to 3 and also updated its Docker image from Ubuntu 16.04 to 18.04. After the migration I started encountering some really strange behavior when trying to reflect SQL Server tables using SQLAlchemy with the pyodbc driver. Initially, I was seeing this error message: [08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLExecDirectW) I had updated SQLAlchemy from 0.9.8 to 1.3.10 (I hadn't touched pyodbc which was at 3.0.10) so I

SQL Server queries beyond a certain character length are timing out

淺唱寂寞╮ 提交于 2021-02-11 16:30:26
问题 Recently I migrated an ETL platform from Python 2.7 to 3 and also updated its Docker image from Ubuntu 16.04 to 18.04. After the migration I started encountering some really strange behavior when trying to reflect SQL Server tables using SQLAlchemy with the pyodbc driver. Initially, I was seeing this error message: [08S01] [FreeTDS][SQL Server]Read from the server failed (20004) (SQLExecDirectW) I had updated SQLAlchemy from 0.9.8 to 1.3.10 (I hadn't touched pyodbc which was at 3.0.10) so I