Cloud Stack Ninja

import sqlite3 from time import time

#Creation of connection

con=sqlite3.connect('hospitaldb')#creates a db named hospital

with con: #create cursor cur=con.cursor()

#creation of tables
cur.execute("CREATE TABLE IF NOT EXISTs patient_details(id int,first_name text,last_name text,age int,disease text)")

#to check the number of tables in database hospitaldb
cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
print(cur.fetcha11())
rows=cur.fetchall()
for row in rows:
    print(row)

#insert records in patient_details try: cur.execute("INSERT INTO patient_details VALUES (1,'ab','cd',45,'heart Attack')")

except: print("record exists")



Read more here: https://stackoverflow.com/questions/64413669/how-to-solve-sqlite3-cursor-object-has-no-attribute-fetcha11

Content Attribution

This content was originally published by Leafia Dias at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: