As Aaron said, you need to commit your changes. PEP 249 requires that
autocommit be disabled by default. You can either call commit() on your
connection object:
conn = ibm_db_dbi.connect()
cursor = conn.cursor()
cursor.execute('delete from employee')
conn.commit()
or you can enable auto commit:
conn = ibm_db_dbi.connect(conn_options={ibm_db_dbi.SQL_ATTR_AUTOCOMMIT :
ibm_db_dbi.SQL_AUTOCOMMIT_ON})
cursor = conn.cursor()
cursor.execute('delete from employee')
See the documentation for more info.
[1]
https://www.python.org/dev/peps/pep-0249/#commit
Kevin Adler
Software Development - PASE, Open Source, IBM i Access ODBC
----- Original message -----
From: Aaron Bartell <aaronbartell@xxxxxxxxx>
Sent by: "OpenSource" <opensource-bounces@xxxxxxxxxxxx>
To: IBMi Open Source Roundtable <opensource@xxxxxxxxxxxx>
Cc:
Subject: Re: [IBMiOSS] using ibm_db_dbi to block insert
Date: Tue, Oct 10, 2017 4:17 PM
Check to make sure you have it either auto committing or are issuing an
SQL
commit.
Aaron Bartell
IBM i hosting, starting at $157/month. litmis.com/spaces
On Tue, Oct 10, 2017 at 4:13 PM, Jeremy Meyer <JMeyer@xxxxxxxxxxxxx>
wrote:
> We just got ibm_db_dbi installed and I have been trying it out. I have
no
> issue retrieving information but cannot seem to be able to insert.
>
> Using cursor.executemany() I am trying to insert several rows. Table
is
> just a big list of tuples.
>
> cur.executemany('insert into lib.table
(LIBNAME,LIBTYPE,TO_LVL,TO_ENV,LIBAPP,MST_OWNER)
> values (?,?,?,?,?,?)',table)
>
> Rough idea of what Table looks like.
> <class 'list'>: [('LIBONE', 'DTA', Decimal('10'), 'SomeText', 'XXXX',
> 'NameasText '), ('LIBTWO', 'DTA', Decimal('10'), 'SomeText',
'XXXX',
> 'NameasText ')]
>
> So it executes the statement like it is successful, but I never get
any
> data inserted into my table. I haven't found any examples anywhere yet
> using ibm_db_dbi for inserting.
> NOTICE: This electronic mail message and any files transmitted with it
are
> intended
> exclusively for the individual or entity to which it is addressed. The
> message,
> together with any attachment, may contain confidential and/or
privileged
> information.
> Any unauthorized review, use, printing, saving, copying, disclosure or
> distribution
> is strictly prohibited. If you have received this message in error,
please
> immediately advise the sender by reply email and delete all copies.
> --
> This is the IBMi Open Source Roundtable (OpenSource) mailing list
> To post a message email: OpenSource@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit:
[2]
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=MoDEjINyy2UvJwnFnQRDTNMbYuAgRNMa7PlkGIrzy8w&e=
> or email: OpenSource-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at
[3]
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=W3ehaB19iZkOru_X2dBsm8vc7GYzwyytENFw-6MqBpw&e=.
>
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
[4]
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=MoDEjINyy2UvJwnFnQRDTNMbYuAgRNMa7PlkGIrzy8w&e=
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
[5]
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=W3ehaB19iZkOru_X2dBsm8vc7GYzwyytENFw-6MqBpw&e=.
References
Visible links
1.
https://www.python.org/dev/peps/pep-0249/#commit
2.
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=MoDEjINyy2UvJwnFnQRDTNMbYuAgRNMa7PlkGIrzy8w&e=
3.
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=W3ehaB19iZkOru_X2dBsm8vc7GYzwyytENFw-6MqBpw&e=
4.
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.midrange.com_mailman_listinfo_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=MoDEjINyy2UvJwnFnQRDTNMbYuAgRNMa7PlkGIrzy8w&e=
5.
https://urldefense.proofpoint.com/v2/url?u=https-3A__archive.midrange.com_opensource&d=DwICAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2aXRESXNvBGuLbIQEybCPNLc7OK0UqjwsZsoCq7Jz6o&m=KBp1XfevIJuPOMIZWDEw5qoEy5YmlU8iXwp-uH3fpY4&s=W3ehaB19iZkOru_X2dBsm8vc7GYzwyytENFw-6MqBpw&e=
As an Amazon Associate we earn from qualifying purchases.