Answers for "python setup sqlite3"

SQL
6

install sqlite3 python

pip install pysqlite3
Posted by: Guest on September-12-2020
5

python sqlite3 database

import sqlite3

# Create database
conn = sqlite3.connect('tablename.db')
c = conn.cursor()
c.execute('''CREATE TABLE tablename(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, number REAL)''')
conn.commit()
conn.close()

# Insert Values
conn = sqlite3.connect('tablename.db')
c = conn.cursor()
c.execute("INSERT INTO tablename VALUES (?, ?)", (name, number))
conn.commit()
conn.close()

# Read Values
conn = sqlite3.connect('tablename.db')
c = conn.cursor()

for row in c.execute('SELECT * FROM tablename'):
	print(row)

number = [row[2] for row in c.execute('SELECT * FROM tablename')]
conn.close()
Posted by: Guest on June-27-2021
6

how to install sqlite3 in python

if you are using python3, sqlite3 is built in into it.
Posted by: Guest on December-13-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language