mx.ODBC minor problem

G

Greg Corradini

Hello all,
In a script i just wrote, my code calls a function createTables(), which
checks for an existing table and then creates it, and then immediately calls
selectSQL(), which selects from a different table and inserts on the table I
just created (see below).

However, I continue to get an Interface Error (see below) when i run it. And
yet, if I allow the code to call createTables() and then manually call
selectSQL() after a couple seconds, the thing works fine. In short, there's
no mismatch in the number of parameters. Why would this be? I've never
experienced this before. How can i restructure my code to resolve this
problem?
---
CODE
---
def createTables():
# Drop AddScript Table
try:
curse.execute('Drop table ' +countyname+'ADD_SCRIPT_TABLE')
conn.commit
except:
pass
# Create AddScript Table
curse.execute('Create table ' +countyname+'ADD_SCRIPT_TABLE'+ ' (TISCODE
TEXT(12), STATUS TEXT(4))')
conn.commit()

def selectSQL():
sql = "Select TISCODE,STATUS from " +countyname+"0"+ " where STATUS =
'AS'"
curse.execute(sql)
a = curse.fetchall()
curse.executemany('Insert into ' +countyname+'ADD_SCRIPT_TABLE'+ '
(TISCODE,STATUS) values (?,?)',x)
conn.commit()
 
D

Dennis Lee Bieber

def createTables():
# Drop AddScript Table
try:
curse.execute('Drop table ' +countyname+'ADD_SCRIPT_TABLE')
conn.commit
except:
pass
# Create AddScript Table
curse.execute('Create table ' +countyname+'ADD_SCRIPT_TABLE'+ ' (TISCODE
TEXT(12), STATUS TEXT(4))')
conn.commit()

def selectSQL():
sql = "Select TISCODE,STATUS from " +countyname+"0"+ " where STATUS =
'AS'"
curse.execute(sql)
a = curse.fetchall()
curse.executemany('Insert into ' +countyname+'ADD_SCRIPT_TABLE'+ '
(TISCODE,STATUS) values (?,?)',x)
conn.commit()

Insufficient information. Where is the code invoking these
functions?

WHERE does "countyname" get defined? You appear to be relying on
global variables rather than passing them into the functions.

WHERE is "x" defined -- you are doing a fetch into "a", but using
"x" for the parameter.

If "a" returns only a single row, is it possible executemany() may
object?



--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top