Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indentation error... lol
#1
Getting an indentation error which is usually indicative of a syntax error ELSEWHERE in the code (a big weakness of Python).

Code:

import csv
import os
import sys
import PyGUITools as pg 
import sqlite3
rootpath = os.path.dirname(__file__)


class DBObject():  #args here are for inheritance
    
    def __init__(self,path):
        self.path = path

        self.conn = sqlite3.connect(self.path)
        self.c = self.conn.cursor()
        self.filename = os.path.basename(self.path)
        self.dbname = os.path.splitext(self.filename)[0]

    def CreateTable(self,tablename):

        sql = "CREATE TABLE [IF NOT EXISTS] [" + self.dbname + "]." + tablename + " (ID data_type PRIMARY KEY"
        #self.ExecuteSQL(sql)

    def ExecuteSQL(self,sql):
        c = self.c
        c.execute(sql)
        conn = self.conn
        conn.commit()
        
    def TableCount(self):
        sql =  "SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name != 'android_metadata' AND name != 'sqlite_sequence';"
        #self.ExecuteSQL(sql)

    class TableDefs():

        def __init__(self,tablename):
            
        def Wipe(self):

        def Copy(self):

        def AddField(self):

        class Fields():

            def __init__(self,fieldname):
                self.fieldname = fieldname

            def Count(self):

            def Add(name,type="text"):

            def Edit(self):

mypath = os.path.join(rootpath,"Test1.db")
db = DBObject(mypath)
db.CreateTable("MyTable")
P.S - if you comment out this block....

    def ExecuteSQL(self,sql):
        c = self.c
        c.execute(sql)
        conn = self.conn
        conn.commit()
It suddenly runs :) lol but python said it was an "indentation" error......
Reply


Messages In This Thread
Indentation error... lol - by ironfelix717 - Apr-01-2020, 05:13 PM
RE: Indentation error... lol - by j.crater - Apr-01-2020, 05:39 PM
RE: Indentation error... lol - by stullis - Apr-01-2020, 05:40 PM
RE: Indentation error... lol - by buran - Apr-01-2020, 06:30 PM
RE: Indentation error... lol - by ironfelix717 - Apr-02-2020, 05:45 AM
RE: Indentation error... lol - by buran - Apr-02-2020, 06:09 AM
RE: Indentation error... lol - by ironfelix717 - Apr-02-2020, 02:19 PM
RE: Indentation error... lol - by stullis - Apr-02-2020, 02:24 PM
RE: Indentation error... lol - by buran - Apr-02-2020, 02:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Indentation Error With If Else Statement JoeDainton123 3 1,885 Aug-02-2020, 08:29 PM
Last Post: deanhystad
  Getting error message for indentation Shafla 5 2,933 May-07-2019, 08:56 PM
Last Post: Yoriz
  Help please - indentation error bil007 1 2,107 Mar-24-2019, 11:41 AM
Last Post: Yoriz
  Very strange error of indentation samsonite 12 5,413 Mar-22-2019, 10:45 AM
Last Post: samsonite
  Indentation error in Python code ErnestTBass 5 3,658 Feb-28-2019, 04:26 PM
Last Post: samsonite
  Class - Error Message (Indentation) tkj80 3 4,567 Jan-20-2017, 07:48 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020