× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Thu, Feb 10, 2022 at 2:25 PM Jack Woehr via MIDRANGE-L
<midrange-l@xxxxxxxxxxxxxxxxxx> wrote:

Here's a demo.

1. I create two tables, one with two 100-varchar fields, another with
one.
2. I fill the first table with 26 rows with the whole row filled with
that letter of the alphabet (1-26).
3. I fill the second table by splitting the each row of the first table
and making two rows in the second.

I don't consider a table with two 100-varchar fields the same thing as
a table with one 200-varchar field that you then have to split. You're
hand-waving away the core feature of OP's problem.

But the reason I'm writing this is to present a more idiomatic version
of your code. If you're trying to show off Python's power and
conciseness, it would be a little better as below. Also, there's no
reason you couldn't have done the iACS stuff (for step 1) in Python as
well.

In Python:
from string import ascii_lowercase

import pyodbc

cn = pyodbc.connect("DSN=*LOCAL")
c200 = cn.cursor()
c100 = cn.cursor()

q2 = "select field1, field2 from jaxtest.a"
q2i = "insert into jaxtest.a (field1, field2) values(?, ?)"
q1i = "insert into jaxtest.b (field1) values(?)"

try:
for c in ascii_lowercase:
sl = c * 100
c200.execute(q2i, sl, sl)
c200.commit()
for row in c200.execute(q2).fetchall():
c100.execute(q1i, row[0])
c100.execute(q1i, row[1])
c100.commit()
finally:
c200.close()
c100.close()
cn.close()

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.