Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Using VBA to Call a Python script causes error in pyodbc connector
Hello, I am using vba to call a python script that gets information from a Jira API and uses pyodbc to update an Access database. Everything works fine if I open the python script and run it from an interpreter, but if i use vba to call the script I get the below error.

Traceback (most recent call last): File "C:\Users\PCarra\Desktop\CktOpsDb\Scripts\", line 7, in <module> conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=\\**Omitted on purpose**\Backend\Inventory_be.accdb;')pyodbc.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
Python code below:

from collections import Counter
from jira import JIRA
from pprint import pprint
import requests, json, urllib3, os, pyodbc, usaddress

#Connection string for database
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=\\**omitted on 
cursor = conn.cursor()
                UPDATE CircuitInfoTable
                SET CircuitID = ?, Bandwidth = ?, Region = ?, HandoffALocAddress = ?, HandoffALocCity = ?, HandoffALocST = ?, 
                Carrier = ?, HandoffZLocAddress = ?, HandoffZLocCity = ?, HandoffZLocST = ?, SegmentID = ?, Legacy = ? WHERE 
                LatestJiraTicket = ? 
                ''', params)

VBA call to script:

Dim x As Variant Dim strProgramName As String strProgramName = CurrentProject.Path & "\Scripts\" Shell Environ$("COMSPEC") & " /k" & strProgramName, vbNormalFocus
Any ideas on what may be causing the above error since it works through an interpreter but not after I call the script using VBA?

Thanks for the help!
Yoriz wrote Jun-10-2019, 09:02 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
I found my problem from within the shell called from vba I needed to specify a 32 bit version of python to execute the script. Also I created a System DNS connector on my system. Not a python code problem. Sorry!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Call pip3 from python folder build by me call pip3 from the /usr/bin Suryavarman 3 178 Oct-07-2019, 10:23 PM
Last Post: Suryavarman
  Trouble retrieving dictionary from mysql.connector cursor swechsler 2 156 Sep-17-2019, 05:21 PM
Last Post: swechsler
  PYTHON Script ERROR Help Need alex9745 3 212 Sep-17-2019, 08:37 AM
Last Post: alex9745
  pyodbc.Error SQLBindParameter pcarra 0 250 Jul-08-2019, 08:22 PM
Last Post: pcarra
  API Call Gets 404 Error jimbone30 0 227 Jun-28-2019, 04:06 AM
Last Post: jimbone30
  Pyodbc error taxit 1 555 Jun-18-2019, 01:13 AM
Last Post: Larz60+
  call dict object result key error lateublegende 2 373 May-15-2019, 01:08 PM
Last Post: lateublegende
  Package python script which has different libraries as a single executable or script tej7gandhi 1 322 May-11-2019, 08:12 PM
Last Post: keames
  Split List and Sublist from Pyodbc parthi1705 1 322 May-05-2019, 10:44 AM
Last Post: Larz60+
  Add a stored procedure with variable using MySQL Connector UtiliseIT 0 226 May-04-2019, 12:46 PM
Last Post: UtiliseIT

Forum Jump:

Users browsing this thread: 1 Guest(s)