Category : pyodbc

The following script connects to two databases, when it executes the update statement, the script crashes with> Exit code: 3221225477 #!/usr/bin/env python # -*- coding: iso-8859-1 -*- import sys reload(sys) sys.setdefaultencoding(‘iso-8859-1’) import pyodbc print("pyodbc " + pyodbc.version) import locale locale.setlocale(locale.LC_ALL, ”) import datetime database = "W:ARCHIVIELISA.DBD" #first Database user = "user" password = "password" connessione ..

Read more

I have the following code: self.cursor.execute("""UPDATE Names SET Format = ?, FoodServiceBulkPack = ?, EachUPC = ?, EachWeight = ?, EachUOM = ?, QtyPerInner = ?, InnerPackUPC = ?, InnerWeight = ?, InnerUOM = ?, QtyPerCase = ?, CaseUPC = ?, CaseWeight = ?, CaseUOM = ?, QtyCasesperPallet = ?, CaseGTIN = ?, [Short Description] ..

Read more

I am newbie to sql query .. I am writing code and querying database in python.. Below is my code and I am not sure about the problem with the code: import pyodbc import pandas as pd import numpy as np #import datetime from pandas import ExcelWriter from pandas import ExcelFile df_lots=pd.DataFrame() sql = """ ..

Read more

I have a csv files that I’m turning into a pandas dataframes (df), then manipulating the values in a couple of columns, and finally exporting the dataframe to a table in SQL Server. The code is: import pyodbc import sys df = pd.read_csv(f’../data/polreg/{sys.argv[3]}’, usecols=[0, 1, 2, 3, 4, 5, 8, 10, 11, 17, 18, 20]) ..

Read more

I am trying to connect to an hfsql database using python. I found this syntax on a forum : cnxn = pyodbc.connect(‘Driver={HFSQL};’ ‘Server Name=XXXXX;’ ‘Database=XXXXX;’ ‘UID=XXXXX;’ ‘PWD=XXXX;’ "Server Port=XXXX;" ) cursor = cnxn.cursor() cursor.execute(‘SELECT TOP 10 * FROM mytable’) for row in cursor: print(row) The issue is that when I execute this code on jupyter ..

Read more

I made a code which gather datas from files and I want to put them in a database using pyodbc in python and SQL server express 2019. Here is my code : import pyodbc conn = pyodbc.connect(‘Driver={SQL SERVER};’ ‘Server=<my server>;’ ‘Database=<my database>;’ ‘Trusted_Connection=yes;’ cursor=conn.cursor() sql=""" INSERT INTO [dbo].[<my table>] ([data1] ,[data2] ,[data3] ,[data4]) VALUES (‘{0}’ ..

Read more

import pyodbc import pandas as pd # Connection string conx_string = "driver={SQL Server Native Client 11.0}; server=; database=; UID=; PWD=" # Query to run query = """ select new_name, CreatedOn, new_status, new_PaperApplicationSubmitted from new_application where createdon >= ’01-Feb-2021′ and CreatedOn <= ‘1-Mar-2021’ and new_ApplicationType = 2 and new_PaperApplicationSubmitted = 1 """ # Creating connection and ..

Read more