I was looking for any database solution with Python. And found the tutorial Python: A Simple Step-by-Step SQLite Tutorial. There I found a code example which shows how to create a database and INSERT some data:
import sqlite3
conn = sqlite3.connect("mydatabase.db") # or use :memory: to put it in RAM
cursor = conn.cursor()
# create a table
cursor.execute("""CREATE TABLE albums
(title text, artist text, release_date text,
publisher text, media_type text)
""")
I am totally new to sqlite3.
- If I want to use
sqlite3do I need to install any particular Python modules? - In the above code I can see one database named
mydatabase.db. How do I create that database?
If anyone help me to get these confusions cleared from my head, I can give these new module a good start.
Thanks
You don’t need (to install) any additional Python modules to use sqlite3.
If the database doesn’t exist, it will be automatically created usually in the same directory as the script.
On running your script, I get this :-