pyodbc

Getting Table and Column names in PyOdbc

馋奶兔 提交于 2020-06-09 12:07:32
问题 I'd like to retrieve the fully referenced column name from a PyOdbc Cursor. For example, say I have 2 simple tables: Table_1(Id, < some other fields >) Table_2(Id, < some other fields >) and I want to retrieve the joined data select * from Table_1 t1, Table2 t2 where t1.Id = t2.Id using pyodbc, like this: query = 'select * from Table_1 t1, Table2 t2 where t1.Id = t2.Id' import pyodbc conn_string = '<removed>' connection = pyodbc.connect(conn_string) cursor = connection.cursor()cursor.execute

SQL server connection works fine from lambda container but fails after uploading zip to aws lambda

空扰寡人 提交于 2020-06-09 05:20:09
问题 I was following this medium blog to try to establish a connection to a MSSQL db from a lambda function. I used lambci/lambda:build-python3.8 image to build the container. I followed all the steps mentioned and was able to successfully run the python test script that verifies the connection. Below is the content of the zip file inside the container. However, when I zip it up and upload to lambda, I am receiving below error. START RequestId: 6f3ec44e-aac0-4cc3-b5ed-f8935c4dff4d Version: $LATEST

How to put variable in `pyodbc` query?

孤人 提交于 2020-05-18 04:27:50
问题 I am using pyodbc to save data in Microsoft SQL Server. I 3 string variables, user_first_name , user_last_name and profile_photo_path user_first_name = 'Shams' user_last_name = 'Nahid' file_name = 'my_profile_photo_path' Now when I try to save data using cursor.execute(f''' INSERT INTO pyUser.dbo.user_information (first_name, last_name, profile_photo_path) VALUES ({user_first_name}, {user_last_name}, {file_name}) ''') I get the following error Invalid column name \'Shams\'. Invalid column

How to put variable in `pyodbc` query?

六月ゝ 毕业季﹏ 提交于 2020-05-18 04:25:15
问题 I am using pyodbc to save data in Microsoft SQL Server. I 3 string variables, user_first_name , user_last_name and profile_photo_path user_first_name = 'Shams' user_last_name = 'Nahid' file_name = 'my_profile_photo_path' Now when I try to save data using cursor.execute(f''' INSERT INTO pyUser.dbo.user_information (first_name, last_name, profile_photo_path) VALUES ({user_first_name}, {user_last_name}, {file_name}) ''') I get the following error Invalid column name \'Shams\'. Invalid column

【软件安装教程】python模块的安装

佐手、 提交于 2020-05-09 16:23:36
#官网: https://www.python.org/ # python 模块的安装,可先去 python 库里下载安装包,本地安装; 也可直接使用cmd / Anacoda 等工具 在线安装 # python 库 https://www.cnblogs.com/lgx-fighting/p/9398721.html 1.python爬虫常用第三方库: https://blog.csdn.net/woshisunchi/article/details/60877817 2.python数据挖掘常用包: https://blog.csdn.net/sunflower606/article/details/49738107 3.库: https://pypi.org/ https://pypi.org/search/?q=scipy https://pypi.org/simple/tensorflow/ https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud https://code.google.com/archive/p/pyodbc/downloads https://digi.bib.uni-mannheim.de/tesseract/ https://mirrors.tuna.tsinghua.edu.cn/ 1、使用

Pyodbc + sqlalchemy fails for more than 2100 items

折月煮酒 提交于 2020-05-08 16:55:28
问题 In the below code, an error is thrown when employee_code_list is longer than 2000 items as mentioned below. However, it works perfectly when the list is under 2000 items. query = session.query(TblUserEmployee, TblUser).filter( and_( (TblUser.UserId == TblUserEmployee.EmployeeId), (func.lower(TblUserEmployee.EmployeeCode).in_(employee_code_list)), (TblUser.OrgnId == MIG_CONSTANTS.context.organizationid), (TblUser.UserTypeId == user_type) )) results = query.all() This is the relevant part of

Read database into dataframe using pyodbc with parameterized query

烈酒焚心 提交于 2020-03-27 05:09:24
问题 I'm using pyodbc to get data from a SQL Server, using the script shown here: conn = pyodbc.connect('DSN=DATASOURCE') tbl = "SELECT TableA.Field_1 \ FROM TableA \ WHERE TableA.Date>=2019/04/01" SQL_Query = pd.read_sql_query(tbl, conn) conn.close Now I want to make this query into a Python function, where I can change the date (2019/04/01) in the example above as a function variable. I found pyodbc offers parameterization, but all in the context of cursor.execute function. Ideally, I'd like to

Read database into dataframe using pyodbc with parameterized query

白昼怎懂夜的黑 提交于 2020-03-27 05:08:58
问题 I'm using pyodbc to get data from a SQL Server, using the script shown here: conn = pyodbc.connect('DSN=DATASOURCE') tbl = "SELECT TableA.Field_1 \ FROM TableA \ WHERE TableA.Date>=2019/04/01" SQL_Query = pd.read_sql_query(tbl, conn) conn.close Now I want to make this query into a Python function, where I can change the date (2019/04/01) in the example above as a function variable. I found pyodbc offers parameterization, but all in the context of cursor.execute function. Ideally, I'd like to

Authenticate from Linux to Windows SQL Server with pyodbc

时间秒杀一切 提交于 2020-03-17 10:56:17
问题 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

Authenticate from Linux to Windows SQL Server with pyodbc

流过昼夜 提交于 2020-03-17 10:55:25
问题 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