samedi 8 août 2015

Error while creating table SQLite Python

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?

Aucun commentaire:

Enregistrer un commentaire