Reputation: 474
I am trying to run this simple "program"
import sqlite3
CIP_InvoiceDB = 'CIP_Invoice.db'
conn = sqlite3.connect(CIP_InvoiceDB)
c = conn.cursor
print('Connection opened')
c.execute('''CREATE TABLE Cliente (
DNI INT PRIMARY KEY,
Nombre TEXT NOT NULL,
Apellido TEXT NOT NULL,
Tipo TEXT DEFAULT 'Cliente') WITHOUT ROWID;
''')
print('Table created')
And I get this error in the command line when triggering it:
Connection opened
Traceback (most recent call last):
File "createDB.py", line 7, in <module>
c.execute('''CREATE TABLE Cliente (
AttributeError: 'builtin_function_or_method' object has no attribute 'execute'
What am I doing wrong? Also I don't understand why there is a lot of variations in quotations. I did some research and everywhere I see a create table sentence is inside a triple single quote ('''), Why?
Upvotes: 0
Views: 151
Reputation: 474
I should have used the connection rather than the cursor when doing the executions.
Upvotes: 0