Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Simple mx.ODBC prob seeks simple answer

Reply
Thread Tools

Simple mx.ODBC prob seeks simple answer

 
 
Greg Corradini
Guest
Posts: n/a
 
      04-06-2007

Hello all,
I'm having trouble inserting an SQL selection into a new MS Access table. I
get a parameter error on my insert statement when I try this (see below for
code and error msg). I'm not sure if 'insert' or 'update' is the route I
should be taking.

CODE:
#Import Pythond Standard Library Modules
import win32com.client, sys, os, string, copy, glob
import mx.ODBC.Windows as odbc

# Create the Geoprocessor Object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDisp atch.1")
gp.overwriteoutput = 1

# Variables
tempspace = "C:\Documents and Settings\corr1gre\Desktop\Workspace\DBFs &
Shapefiles\TEST.mdb"
workspace = string.replace(tempspace,"\\","/")
worksheet1 = "Mower_I"
worksheet2 = "Mower_II"

#Conection to Access
driv = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+workspace
conn = odbc.DriverConnect(driv)
curse = conn.cursor()

#Drop Tables if they already exist
try:
curse.execute('Drop table Table_I')
curse.execute('Drop table Table_II')
curse.execute('Drop table Checker')
except:
pass
#Create a New Tables
curse.execute('Create table Table_I (TISCODE TEXT(12), EXISTSIN
TEXT(4),STATUS TEXT(3),NOTES TEXT(50))')
curse.execute('Create table Table_II(TISCODE TEXT(12), EXISTSIN TEXT(4))')
curse.execute('Create table Checker (TISCODE TEXT(12), EXISTSIN
TEXT(4),STATUS TEXT(3),NOTES TEXT(50))')
conn.commit()

#Upload DBF 1 as a List of Tuples: Returns tuple as ('1021500000','BMP')
sql = 'SELECT TISCODE,EXISTSIN from '+worksheet2
curse.execute(sql)
x = curse.fetchall()

#Put the fetched Data into Table_II
for i in x:
curse.execute('Insert into Table_II (TISCODE,EXISTSIN) values
(%s,%s)'%(i[0],i[1]))
conn.commit()
conn.close()

TRACEBACK ERROR MSG:
Traceback (most recent call last):
File "C:/Documents and Settings/corr1gre/Desktop/Workspace/Python/ArcGIS
Python/ExistenceChecker and Update/Access Double Checker/Access_SQL.py",
line 40, in ?
curse.execute('Insert into Table_II (TISCODE,EXISTSIN) values
(%s,%s)'%(i[0],i[1]))
ProgrammingError: ('07001', -3010, '[Microsoft][ODBC Microsoft Access
Driver] Too few parameters. Expected 1.', 4612)
--
View this message in context: http://www.nabble.com/Simple-mx.ODBC....html#a9871804
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio prob that's more than a sound card prob LineOut Computer Support 2 04-19-2008 02:30 PM
Re: Simple mx.ODBC prob seeks simple answer Steve Holden Python 1 04-06-2007 05:09 PM
Wrong answer equals to a blank answer or not? Zadkin Microsoft Certification 8 06-27-2006 01:51 PM
Printer prob and also networking prob Gareth not NLL or anybody else. Computer Support 2 01-02-2004 07:48 PM



Advertisments