I have been running queries in SQL in Python using psycopg2. This is very simple and I just do the following:
conn2 = psycopg2.connect('postgresql://YourUserName:YourPassword@YourHost:5432/YourDatabase')
query = "xxx"
query_output = pd.read_sql_query(query, conn2).drop_duplicates(keep='first')
Is it possible to something similarly as easy in VBA? I am hoping to create an easy-to-use excel add-in so want to avoid asking the user to have to set up 32-bit drivers in ODBC Driver Manager.
I am trying to develop a setup here:
Dim objDb_con
Dim strSomeValue As String
Set objDb_con = CreateObject("ADODB.Connection")
Set Rsdatatype = CreateObject("ADODB.RecordSet")
glbConnString = "Driver={PostgreSQL UNICODE};Database=XX;port=XX;server=XX;UID=XX;Pwd=XX;"
objDb_con.Open glbConnString
But I get the error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Looking around it appears this is to do with ODBC driver managers and even though I tried to set-up the default as 32-bit I still get this error.
Is there a psycopg2-style alternative for VBA that is simple and doesn't require set-up for the user?