Connecting Anaconda with Access Database using Pyodbc

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Database
AI Thread Summary
The discussion revolves around troubleshooting a Python code error encountered while trying to connect to an Access Database using Pyodbc in Anaconda Jupyter. The error message indicates a syntax issue, specifically an "EOL while scanning string literal," suggesting a missing single quote in the connection string. Participants discuss the importance of using descriptive names for programs and variables to improve code readability and maintainability. There is also a brief exchange about remembering file locations and the utility of command-line tools in programming. Additionally, a link to a resource on connection strings is shared, highlighting the challenges faced with ODBC drivers and database connections. Overall, the conversation emphasizes debugging techniques and best practices in coding.
WWGD
Science Advisor
Homework Helper
Messages
7,700
Reaction score
12,736
TL;DR Summary
Trying to connect Anaconda with Access Db using Pyodbc , getting 'EOL String
Hi All,
My goal is to access an Access Database from within Anaconda Jupyter and , in Jupyter, use Pyodbc to conduct dynamic queries against my database and do some plotting of the data in Access. My code is below, together with the error message
--------------------------------------------------------------------------------------

1579657834845.png
Error message is:
File "<ipython-input-6-eabb548dc75e>", line 3
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ ="C:\AccessDbFiles\BillsPyodbc.accdb")
^
SyntaxError: EOL while scanning string literal

-----------------------------------------------------------------------------
Any ideas?
 
Technology news on Phys.org
I notice the close paren is red maybe you are missing a single quote character.

r’blah blah “blah” ‘
 
  • Like
Likes WWGD
jedishrfu said:
I notice the close paren is red maybe you are missing a single quote character.

r’blah blah “blah” ‘
Thanks, will check out tmw, just left coffee shop.
 
  • Like
Likes jedishrfu
Untitled47? How do you remember where anything is?
 
Borg said:
Untitled47? How do you remember where anything is?
I have my own system until I learn. Maybe not the best but somehow works.
 
A real programmer let's the computer tell them where they are.
 
jedishrfu said:
A real programmer let's the computer tell them where they are.
?? Not sure I get it.
 
Have you ever used the pwd command in linux? or the date or time commands? or even better the uname -a command?

Each of these commands tells you something about where you are or when you are or what machine you're on and there are many others that tell things you might need to know.
 
Borg said:
Untitled47? How do you remember where anything is?
WWGD said:
I have my own system until I learn. Maybe not the best but somehow works.
Definitely not the best, and I doubt it would work over a longer time span than a week or two.
If you take a small amount of time now to come up with names for your programs and variables (recalling another thread of yours) that are indicative of what they will do, it will really pay dividends when you are looking for examples of specific techniques or are trying to understand what your code is doing when you or others look at it a month or more later.
jedishrfu said:
Each of these commands tells you something about where you are or when you are or what machine you're on and there are many others that tell things you might need to know.
Borg's comment wasn't about where the programmer was, but was instead a comment on using uninformative program names such as Untitled47.
 
  • #10
Thanks @Mark44 but I was responding to @WWGD who asked about my real programmer humor while awaiting if the single quote was the issue in his code which I think it was.
 
  • #11
jedishrfu said:
Thanks @Mark44 but I was responding to @WWGD who asked about my real programmer humor while awaiting if the single quote was the issue in his code which I think it was.
It wasn't clear that your reply referred back to what WWGD said. In the interim, Borg asked "How do you remember where anything is?" -- so your comment seemed to me to be a non sequitur.
 
  • Like
Likes jedishrfu
  • #12
jedishrfu said:
I notice the close paren is red maybe you are missing a single quote character.

r’blah blah “blah” ‘
SyntaxError: EOL while scanning string literal
makes this a cast iron certainty - the parser is telling you that it reached the end of the line before it reached the end of the string!

Somtimes error messages are not very helpful, but you should always read them in case they are :rolleyes:
 
  • Like
Likes WWGD, Timo and jedishrfu
  • #13
  • #14
Thanks, that brought back nightmares of projects long ago using DB2 and related hardware/software issues of broken connections.
 
  • #15
jedishrfu said:
Thanks, that brought back nightmares of projects long ago using DB2 and related hardware/software issues of broken connections.
In case it helps, I am having a few of my own, with nightmares about odbc drivers.
 
  • Like
Likes jedishrfu
  • #16
It seems that Computus, ruler of IT world, granted me the miracle of conecting through named pipes to use sqlcmd. A complete blur; I have no clue how it came to happen.
 
  • Like
Likes pbuk
Back
Top