summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py
diff options
context:
space:
mode:
Diffstat (limited to 'kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py')
-rw-r--r--kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py
index 0b78bfa1..20b81212 100644
--- a/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py
+++ b/kexi/plugins/scripting/scripts/copycenter/CopyCenterPluginKexiDB.py
@@ -104,33 +104,33 @@ class CopyCenterPlugin:
self.copierer = copierer
if self.kexidbconnection == None:
if self.plugin.widget == None:
- raise "No connection established."
+ raise Exception("No connection established.")
self.copierer.appendProgressMessage("<i>Trying to connect...</i>")
if self.plugin.widget.driverbox.driver == None:
- raise "Invalid driver."
+ raise Exception("Invalid driver.")
if not self.plugin.widget.connectClicked():
- raise "Failed to connect."
+ raise Exception("Failed to connect.")
connectiondata = self.kexidbconnection.data()
self.copierer.appendProgressMessage("Connected: %s %s" % (connectiondata.driverName(),connectiondata.serverInfoString()))
tablename = str(self.plugin.widget.tablebox.tableedit.text())
if tablename == "":
- raise "No table defined"
+ raise Exception("No table defined")
fields = [ f.strip() for f in str(self.plugin.widget.fieldbox.fieldsedit.text()).split(",") if len(f) > 0 ]
if len(fields) < 1:
- raise "No fields defined"
+ raise Exception("No fields defined")
self.tableschema = self.kexidbconnection.tableSchema(tablename)
- if not self.tableschema: raise "No such tableschema \"%s\"" % tablename
+ if not self.tableschema: raise Exception("No such tableschema \"%s\"" % tablename)
self.copierer.appendProgressMessage("Table: %s" % self.tableschema.name())
if len(fields) == 1 and fields[0] == "*":
self.fieldlist = self.tableschema.fieldlist()
else:
self.fieldlist = self.tableschema.fieldlist().subList(fields)
- if not self.fieldlist: raise "No such fields \"%s\"" % fields
+ if not self.fieldlist: raise Exception("No such fields \"%s\"" % fields)
fieldlistnames = self.fieldlist.names()
- if len(fieldlistnames) < 1: raise "No valid fields defined for \"%s\"" % fields
+ if len(fieldlistnames) < 1: raise Exception("No valid fields defined for \"%s\"" % fields)
self.copierer.appendProgressMessage("Fields: %s" % fieldlistnames)
def finish(self):
if self.plugin.widget == None:
@@ -146,24 +146,24 @@ class CopyCenterPlugin:
return self.copierer == None
def initRead(self):
- print "Initialize read"
+ print("Initialize read")
#queryschema = self.plugin.copycenterplugin.drivermanager.querySchema()
queryschema = self.tableschema.query()
queryschema.fieldlist().setFields(self.fieldlist)
- print "QuerySchema: %s" % queryschema.fieldlist().names()
+ print("QuerySchema: %s" % queryschema.fieldlist().names())
whereexpression = str(self.plugin.widget.whereedit.text())
if whereexpression != "":
- print "WHERE-expression: %s" % whereexpression
+ print("WHERE-expression: %s" % whereexpression)
if not queryschema.setWhereExpression(whereexpression):
- raise "Invalid WHERE-expression."
+ raise Exception("Invalid WHERE-expression.")
#print "QuerySchema statement=%s" % queryschema.statement()
self.kexidbcursor = self.kexidbconnection.executeQuerySchema(queryschema)
if not self.kexidbcursor:
- raise "Failed to create cursor."
+ raise Exception("Failed to create cursor.")
if not self.kexidbcursor.moveFirst():
- raise "The cursor has no records to read from."
+ raise Exception("The cursor has no records to read from.")
def readRecord(self):
if self.kexidbcursor == None or self.kexidbcursor.eof():
@@ -176,15 +176,15 @@ class CopyCenterPlugin:
return record
def initWrite(self):
- print "Initialize write"
+ print("Initialize write")
def writeRecord(self,record):
- print "write record: %s" % record
+ print("write record: %s" % record)
if self.kexidbconnection.insertRecord(self.fieldlist,record):
- print "=> insert successfully"
+ print("=> insert successfully")
self.copierer.writeSuccess(record, 1)
else:
- print "=> insert failed: %s" % self.kexidbconnection.lastError()
+ print("=> insert failed: %s" % self.kexidbconnection.lastError())
self.copierer.writeFailed(record)
#import time
#time.sleep(1)
@@ -546,10 +546,10 @@ class CopyCenterPlugin:
connectiondata = self.copycenterplugin.drivermanager.createConnectionDataByFile(file)
if connectiondata == None:
- raise "Unsupported file."
+ raise Exception("Unsupported file.")
drivername = connectiondata.driverName().lower()
- print "driver: %s" % drivername
+ print("driver: %s" % drivername)
for i in range(1,self.driverbox.drivercombo.count()):
if drivername == self.driverbox.drivercombo.text(i).lower():
self.driverbox.drivercombo.setCurrentItem(i)
@@ -570,7 +570,7 @@ class CopyCenterPlugin:
def connectClicked(self):
if self.driverbox.driver == None:
- print "No driver selected."
+ print("No driver selected.")
return False
connectiondata = self.copycenterplugin.drivermanager.createConnectionData()
if self.driverbox.driver.isFileDriver():
@@ -588,18 +588,18 @@ class CopyCenterPlugin:
connectiondata.setPassword(str(self.driverbox.passedit.text()))
connectiondata.setUserName(str(self.driverbox.useredit.text()))
connectiondata.setDatabaseName(str(self.driverbox.dbedit.text()))
- print "Creating connection"
+ print("Creating connection")
connection = self.driverbox.driver.createConnection(connectiondata)
- print "Trying to connect"
+ print("Trying to connect")
if not connection.connect():
qt.TQMessageBox.critical(self,"Failed to connect",connection.lastError())
return False
- print "Use database \"%s\"" % connectiondata.databaseName()
+ print("Use database \"%s\"" % connectiondata.databaseName())
if not connection.useDatabase( connectiondata.databaseName() ):
qt.TQMessageBox.critical(self,"Failed to connect",connection.lastError())
return False
- print "dbnames = %s" % connection.databaseNames()
- print "tablenames = %s" % connection.tableNames()
+ print("dbnames = %s" % connection.databaseNames())
+ print("tablenames = %s" % connection.tableNames())
#self.useDatabase(connection, filename)
self.plugin.connection.kexidbconnection = connection