Apr-01-2020, 05:13 PM
Getting an indentation error which is usually indicative of a syntax error ELSEWHERE in the code (a big weakness of Python).
Code:
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......