“So installieren Sie SQLite3 in Python” Code-Antworten

Python Sqlite

import sqlite3
import os.path

#Connection to the DB
try:
    # Make sure to find the file.db in the script directory
    BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 
    db_path = os.path.join(BASE_DIR, "sqlite.db")
    conn = sqlite3.connect(db_path)

except sqlite3.Error as error:
    print("Failed to read data from sqlite table", error)



# Execute query on the sqlite DB
cur = conn.cursor()
cur.execute("SELECT * FROM tasks")

# Print everything from a table
rows = cur.fetchall()
for row in rows:
        print(row)
    
# Update field 
conn.execute("""UPDATE tasks SET name = \'jhon\'
 where id = 1""")

# close the DB connection 
conn.close() 
Maxime Merveille

So installieren Sie SQLite3 in Python

if you are using python3, sqlite3 is built in into it.
Tahsin

So installieren Sie SQLite3 Python

pip install db-sqlite3
Uptight Unicorn

So installieren Sie SQLite3 in Python

#!/usr/bin/python

import sqlite3

conn = sqlite3.connect('test.db')

print "Opened database successfully";
OSP PRO

Ähnliche Antworten wie “So installieren Sie SQLite3 in Python”

Fragen ähnlich wie “So installieren Sie SQLite3 in Python”

Weitere verwandte Antworten zu “So installieren Sie SQLite3 in Python” auf Sql

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen