How can I user "TRANSACTION; BEGIN" ?

344 views
Skip to first unread message

Jin Lee

unread,
Jul 10, 2016, 11:24:40 PM7/10/16
to PyMySQL Users
Hi~ 

I developed python program with pymysql library.

I want to use the TRANSACTION and BEGIN option with my query.

for example

TRANSACTION;
BEGIN;
insert into ~~~
COMMIT;

How can I use the TRANSACTION; BEGIN; ?

Is the same work connection.begin()  in pymysql library? 

INADA Naoki

unread,
Jul 10, 2016, 11:42:52 PM7/10/16
to pymysq...@googlegroups.com
On Mon, Jul 11, 2016 at 12:24 PM, Jin Lee <rubi...@gmail.com> wrote:
> Hi~
>
> I developed python program with pymysql library.
>
> I want to use the TRANSACTION and BEGIN option with my query.
>
> for example
>
> TRANSACTION;
> BEGIN;
> insert into ~~~
> COMMIT;

I don't know about "TRANSACTION".
Do you mean "BEGIN TRANSACTION"?
If so, it's same to "BEGIN". Don't use twice.

>
> How can I use the TRANSACTION; BEGIN; ?
>
> Is the same work connection.begin() in pymysql library?

Yes. begin() and commit() (or rollback())
>
> --
> You received this message because you are subscribed to the Google Groups
> "PyMySQL Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pymysql-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
INADA Naoki <songof...@gmail.com>

Jin Lee

unread,
Jul 11, 2016, 1:22:44 AM7/11/16
to PyMySQL Users
I means 'transaction begin'.
I modified the source to 

connection.begin()
cursor.execute(sql)
connection.commit()

Thank you!


2016년 7월 11일 월요일 오후 12시 42분 52초 UTC+9, Naoki INADA 님의 말:
Reply all
Reply to author
Forward
0 new messages