Thursday, August 2, 2018

How do I connect to SQLite database using Anaconda(Python)?

When I updated the Windows 10 OS to a new Build of OS, the installation spawned some warnings related to Anaconda. After taking care of the problem the installation completed. I believe the Anaconda I had was replaced by a new install.

The following programs appeared in my control panel:


AnacondaPython_2

This added Anaconda to All Programs as shown:


Anaconda3(x64).png

You can launch the Anaconda console and the console gets displayed:

AnacondaPrompt.png

At the prompt you launch Python as shown:

AnacondaPython.png

The version of Python is 3.6.4.

The Python 3.70b2 was removed from the computer.

Accessing SQLite (My persisted file on the computer) is easy using a cursor:

Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn=sqlite3.connect("C:/Users/Owner/Desktop/Blog2017/MSSS2017/SQLite3_DBS/UsersOwnerApr25.sqlite")
>>> c=conn.cursor()
>>> for row in c.execute('Select * from friends'):
...    print(row)
...
('John', 'Chiavetta', 35)
>>>

No comments: