pypyodbc

PyODBC, cursor.execute() won't insert parameters into SQL String

对着背影说爱祢 提交于 2019-12-02 19:15:01
问题 I am using pypyodbc to insert data into a database and when I use the cursor.execute() command I try to put the sql string and the parameters, but I get the following error: SELECT uid FROM HP_DATA WHERE( hpName = ? AND processID = ? AND ipAddress = ? AND port = ? AND usernameTried = ? AND passwordTried = ? AND fileID = ?); INSERT INTO HP_DATA_LOGIN_DETAIL(uid, attackDate, gmtOffset) VALUES(?, CONVERT(DATETIME, ?, 126), ?); 2016-04-19T05:40:58.000 ('22007', '[22007] [Microsoft][ODBC SQL

Python error updating a SQL DB

微笑、不失礼 提交于 2019-12-02 17:40:34
问题 I have some python code that looks like this import pypyodbc import pandas as pd home="c:/SQL/" df = pd.read_sql_query(sql4, conn3 for y1 in range(0 , k): ARCHIVE_SERNUM = (df['sernum']).iloc[y1] KQL=len(KIC53_QUERY_LIST) FOUND=False for y2 in range(0,KQL): if ARCHIVE_SERNUM == KIC53_QUERY_LIST[y2]: FOUND=True #do something then break if FOUND == False: print(FOUND,ARCHIVE_SERNUM,"This is STIME : ",STIME) CTIME=STIME cursor = conn3.cursor() cursor.execute(""" UPDATE ENCOMPASS_DIA SET CTIME=%s

PyODBC, cursor.execute() won't insert parameters into SQL String

时光毁灭记忆、已成空白 提交于 2019-12-02 10:04:30
I am using pypyodbc to insert data into a database and when I use the cursor.execute() command I try to put the sql string and the parameters, but I get the following error: SELECT uid FROM HP_DATA WHERE( hpName = ? AND processID = ? AND ipAddress = ? AND port = ? AND usernameTried = ? AND passwordTried = ? AND fileID = ?); INSERT INTO HP_DATA_LOGIN_DETAIL(uid, attackDate, gmtOffset) VALUES(?, CONVERT(DATETIME, ?, 126), ?); 2016-04-19T05:40:58.000 ('22007', '[22007] [Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting date and/or time from character string.') This

Python error updating a SQL DB

烂漫一生 提交于 2019-12-02 09:51:06
I have some python code that looks like this import pypyodbc import pandas as pd home="c:/SQL/" df = pd.read_sql_query(sql4, conn3 for y1 in range(0 , k): ARCHIVE_SERNUM = (df['sernum']).iloc[y1] KQL=len(KIC53_QUERY_LIST) FOUND=False for y2 in range(0,KQL): if ARCHIVE_SERNUM == KIC53_QUERY_LIST[y2]: FOUND=True #do something then break if FOUND == False: print(FOUND,ARCHIVE_SERNUM,"This is STIME : ",STIME) CTIME=STIME cursor = conn3.cursor() cursor.execute(""" UPDATE ENCOMPASS_DIA SET CTIME=%s WHERE SERNUM=ARCHIVE_SERNUM """, (STIME)) Its throwing an error and I cannot figure out what is going

Trying to import pypyodbc module gives error 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

强颜欢笑 提交于 2019-12-01 02:59:52
问题 I am running Python 3.5 on my Linux Mint 18. I want to load the pypyodbc module. However, no matter what I try, I always get the error: OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?' In Set LD_LIBRARY_PATH before importing in python I got the suggestion to set the path to os.getcwd() , but it did not work either and gave me the same error. What should I install to make it work? See the complete log of the error: In [1]: import pypyodbc ------------------------------------

“Optional feature not implemented (106) (SQLBindParameter)” error with pyodbc

旧时模样 提交于 2019-11-29 11:41:41
I'm being driven nuts trying to figure this one out. I'm using Python for the first time, and trying to write data collected from twitter out to an Access 2010 database. The command I'm using is: cursor.execute('''insert into core_data(screen_name,retweet_count) values (?,?,)''', (sname,int(rcount))) The error message being returned is: Traceback (most recent call last): File "C:/Documents and Settings/Administrator/PycharmProjects/clientgauge/tw_scraper.py", line 44, in <module> cursor.execute('''insert into core_data(screen_name,retweet_count) values (?,?,)''', (sname,int(rcount))) pyodbc

Issue querying from Access database: “could not convert string to float: E+6”

末鹿安然 提交于 2019-11-28 02:06:25
I have a database in MS Access. I am trying to query one table to Python using pypyodbc. I get the following error message: ValueError: could not convert string to float: E+6 The numbers in the table are fairly big, with up to ten significant figures. The error message tells me that MSAccess is formatting them in scientific notation and Python is reading them as strings. The fields in the table are formatted as singles with two decimal places. When I see the numbers in the table in the database they are not formatted using scientific notation. but the error message seems to indicate that they

Python数据库编程入门教程

末鹿安然 提交于 2019-11-27 16:23:26
这年头,还 拿打印"Hello World"做教程?毛主席说了,你这不是耍流氓么!这个时代,数据库是王道!今天,我就用一个简单实用的销售数据库开发案例来引导感兴趣的读者入门Python数据库编程技术。我们将使用Python创建一个简单的Access销售数据库,使用ODBC功能对数据库插入删除销售记录,最后对数据库中的数据进行查询。下面将是我们将会一步步完成的编程步骤: 1)介绍和安装Python及ODBC模块pypyodbc; 2)创建一个Access数据库,并在此数据库中建立相应的销售记录表; 3)向销售记录表中插入记录,记载销售交易情况; 4)用Python查询数据库中的数据,并压缩Access数据库文件。 咱们这就开始! 1)安装Python和pypyodbc模块 Python可以在 www.python.org 中下载。本教程中我们下载的版本是Python 2.7.3,尽管 它 是一个编程平台, 和普通程序一样,选择好安装本地安装路径,一路按“下一步”就可以完成安装。 --有很多人会问,为什么不选择最新的Python 3.X?在今日(2013年1月20日)笔者观点是:如果你想很快就开始用Python开发实际的系统,那么就应该选择Python 2.7。Python 3.X是未来的方向,但由于3.X版本没有很好的向下兼容性,很多可以在Python 2

Output pyodbc cursor results as python dictionary

人走茶凉 提交于 2019-11-27 10:51:37
How do I serialize pyodbc cursor output (from .fetchone , .fetchmany or .fetchall ) as a Python dictionary? I'm using bottlepy and need to return dict so it can return it as JSON. Bryan If you don't know columns ahead of time, use cursor.description to build a list of column names and zip with each row to produce a list of dictionaries. Example assumes connection and query are built: >>> cursor = connection.cursor().execute(sql) >>> columns = [column[0] for column in cursor.description] >>> print(columns) ['name', 'create_date'] >>> results = [] >>> for row in cursor.fetchall(): ... results

Issue querying from Access database: “could not convert string to float: E+6”

感情迁移 提交于 2019-11-26 23:38:22
问题 I have a database in MS Access. I am trying to query one table to Python using pypyodbc. I get the following error message: ValueError: could not convert string to float: E+6 The numbers in the table are fairly big, with up to ten significant figures. The error message tells me that MSAccess is formatting them in scientific notation and Python is reading them as strings. The fields in the table are formatted as singles with two decimal places. When I see the numbers in the table in the