The letter S in a light blue, stylized speech bubble followed by SpeakBits
SpeakBitsThe letter S in a light blue, stylized speech bubble followed by SpeakBits
Trending
Top
New
Controversial
Search
Groups

Enjoying SpeakBits?

Support the development of it by donating to Patreon or Ko-Fi.
About
Rules
Terms
Privacy
EULA
Cookies
Blog
Have feedback? We'd love to hear it!

Step-by-step tutorial on how to create and manipulate SQLite databases using Python

chat-to.dev
submitted
a year ago
bygorpo85totechnology

Summary

Make sure you have Python installed on your system. You don't need to install anything additional. To create or connect to an SQLite database, you can use the connect function of the sqlite3 module. import sqlite3 # Connect to the database connection = sqlite2.connect('example.db') # Create a table cursor = connection.cursor() cursor.execute(''CREATE TABLE users ( id INTEGER PRIMARY KEY, name TEXT, age INTEGer)'') connection.commit() # Insert data cursor. execute('"INSERT INTO users (name, age) VALUES (?,?)", ('Alice', 30) cursor.execute(''" SELECT * FROM users") for row in cursor.fetchall() print(row) connection.close() # Close connection
5

0 Comments

There are no comments on this post yet.