Connecting Anaconda with Access Database using Pyodbc

  • Thread starter WWGD
  • Start date
  • Tags
    Database
In summary: 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.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.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.
  • #1
WWGD
Science Advisor
Gold Member
7,010
10,477
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
  • #2
I notice the close paren is red maybe you are missing a single quote character.

r’blah blah “blah” ‘
 
  • Like
Likes WWGD
  • #3
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
  • #4
Untitled47? How do you remember where anything is?
 
  • #5
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.
 
  • #6
A real programmer let's the computer tell them where they are.
 
  • #7
jedishrfu said:
A real programmer let's the computer tell them where they are.
?? Not sure I get it.
 
  • #8
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.
 
  • #9
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

What is Anaconda?

Anaconda is a free and open-source distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment. It includes over 1,500 popular data science packages and allows for easy installation and management of libraries, dependencies, and environments.

What is an Access database?

An Access database is a relational database management system (RDBMS) developed by Microsoft. It is commonly used for small to medium-sized databases and is designed for non-technical users to store, manage, and analyze data.

What is Pyodbc?

Pyodbc is an open source Python module that allows programmers to connect to databases using an API that is compliant with the Python DB API 2.0 specification. It allows access to a wide range of databases, including Microsoft Access, SQL Server, Oracle, MySQL, and more.

How do I install Pyodbc?

To install Pyodbc, you can use the "pip" command in your command line interface: "pip install pyodbc". You can also install it using Anaconda by running "conda install -c anaconda pyodbc" in your Anaconda Prompt.

How do I connect Anaconda with an Access database using Pyodbc?

To connect Anaconda with an Access database using Pyodbc, you will need to first establish a connection to the database using the Pyodbc "connect" function. You will need to provide the database name, driver, and credentials. Once the connection is established, you can use the "read_sql" function from Pandas to read data from the database and manipulate it within your Anaconda environment.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Programming and Computer Science
Replies
5
Views
14K
  • STEM Academic Advising
Replies
5
Views
1K
  • Computing and Technology
Replies
7
Views
7K
  • Special and General Relativity
Replies
13
Views
2K
Back
Top