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
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 0 128 May-13-2020, 10:22 PM
Last Post: benthomson
  Python: Call function with variabele? Ending in error. efclem 5 156 Apr-22-2020, 02:35 PM
Last Post: buran
  mysql.connector Nobima 1 118 Apr-10-2020, 12:00 PM
Last Post: Larz60+
  Python script Server list - if condition error razor04 12 557 Jan-27-2020, 09:05 PM
Last Post: razor04
  pyodbc error ('82', '[82] 523 80 (0) (SQLDriverConnect)') paulsuk1982 1 287 Nov-29-2019, 11:05 AM
Last Post: Larz60+
  Call pip3 from python folder build by me call pip3 from the /usr/bin Suryavarman 3 505 Oct-07-2019, 10:23 PM
Last Post: Suryavarman
  Trouble retrieving dictionary from mysql.connector cursor swechsler 2 475 Sep-17-2019, 05:21 PM
Last Post: swechsler
  PYTHON Script ERROR Help Need alex9745 3 430 Sep-17-2019, 08:37 AM
Last Post: alex9745
  pyodbc.Error SQLBindParameter pcarra 0 526 Jul-08-2019, 08:22 PM
Last Post: pcarra
  API Call Gets 404 Error jimbone30 0 356 Jun-28-2019, 04:06 AM
Last Post: jimbone30

Forum Jump:

Users browsing this thread: 1 Guest(s)