newbie: Need Help Moving Data from Kirbybase to Gadfly

D

dc

I am fairly new to python and SQL. I have been trying to move data from
Kirbybase table to a Gadfly table and cannot get it to work. Win XP
with python 2.4, Kirbase 1.9, Gadfly B5.

Complete script shown here, with python traceback.

# get global modules for python
import os
import sys

#get database manager module
from kirbybase import KirbyBase, KBError

# open a database, embedded
db = KirbyBase()
result=db.select('test2.tbl', ['recno'],['*'], returnType='object')

# open Gadfly database for storing data
import gadfly
connection = gadfly.gadfly()
connection.startup("subscription", "pvfd_sql")
cursor = connection.cursor()

# Insert all records into SQL Database
for record in result:
sql="INSERT INTO addresslist (lastname, firstname, address, city,
state, zip_code, phone) VALUES(?, ?, ?, ?, ?, ?, ?)"
cursor.execute(sql,result)
connection.commit()
connection.close

#------------------------------------------------------------------------------
# End of Script
#------------------------------------------------------------------------------



Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.

****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.1.2 ==== No Subprocess ====Traceback (most recent call last):
File "C:\Documents and Settings\timothy volner\Desktop\puryear\move
records to sql.py", line 30, in ?
cursor.execute(sql,result)
File "C:\Python24\lib\site-packages\gadfly\database.py", line 367, in
execute
cs = cs.relbind(database)
File "C:\Python24\lib\site-packages\gadfly\operations.py", line 601,
in relbind
target = self.target = db.get_for_update(name)
File "C:\Python24\lib\site-packages\gadfly\store.py", line 201, in
get_for_update
test = rels[name]
File "C:\Python24\lib\site-packages\gadfly\store.py", line 1043, in
__getitem__
return self.shadow[key]
KeyError: 'ADDRESSLIST'
No matter what I do to data, I always end up with this error.
 
D

dc

I have muddle through this and gotten my script to work. Corrected code
attached.

# get global modules for python
import os
import sys

#get database manager module
from kirbybase import KirbyBase, KBError

# open a database, embedded
db = KirbyBase()
result=db.select('test2.tbl', ['recno'],['*'], returnType='object')

# open Gadfly database for storing data
import gadfly
connection = gadfly.gadfly("subscription", "pvfd_sql")

#connection.startup("subscription", "pvfd_sql")
cursor = connection.cursor()

# Insert all records into SQL Database
for record in result:
ln=str(record.lastname).strip("'")
fn=str(record.firstname).strip("'")
ci=str(record.city).strip("'")
st=str(record.state).strip("'")
ad=str(record.address).strip("'")
zi=str(record.zip).strip("'")
ph=str(record.phone).strip("'")

sql = "INSERT INTO addresslist (lastname, firstname,CITY, STATE,
ADDRESS, ZIPCODE, PHONE) VALUES(?,?,?,?,?,?,?)"
cursor.execute(sql,(ln, fn, ci, st, ad, zi, ph))
print "adding..."
connection.commit()
connection.close

#------------------------------------------------------------------------------
# End of Script
#------------------------------------------------------------------------------
 
D

Dennis Lee Bieber

No matter what I do to data, I always end up with this error.

Off-hand, does your gadfly database even HAVE an "addresslist" table
defined?

IOW; have you created the gadfly database definitions before trying
to insert data into them. (The traceback seems to indicate that the
gadfly logic is trying to find out what "addresslist" is, and doesn't
find it in the definitions).
--
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top