0

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?

2 Answers 2

3

You didn't call the cursor method.

c = conn.cursor()
Sign up to request clarification or add additional context in comments.

Comments

0

I should have used the connection rather than the cursor when doing the executions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.