Menu

Inserting Records - Windows Installation

Help
2005-06-13
2012-09-19
  • bjoernpeters

    bjoernpeters - 2005-06-13

    First of all: Thanks a lot for bringing this library into existence!

    My problem: I had to move code from a linux / debian to a windows machine (XP, mysql 4.1, python 2.4, MySQLdb -1.2.0). Remote access to the debian machine works, but using the local mysql does not. In general, inserting records does not seem to work.

    Sample code:
    cursor.execute("create database newdb")
    cursor.execute("use newdb")
    cursor.execute("create table t1(name varchar(20))")
    cursor.execute("insert into t1values('test')")

    This results in a new database + table being created, but the insert is not executed. No error message is generated.

    Being rather new to handling databases, I am sure I managed to overlook something trivial, but I just don't know what.

    Any input is greatly appreciated!

    Thanks,

    Bjoern

     
    • bjoernpeters

      bjoernpeters - 2005-06-14

      Actually I also had the problem when using the same MySQLdb 1.2 installation from a windows machine and connecting to 1) a local windows MySQL installation and 2) a remote Debian MySQL (4.1.11) installation. For 2) auto commit was left turned on. From what you write I assume that is not the intended behaviour.

      As I said my problems are solved; I just thought the above may be of interest to you.

      Thanks again,

      Bjoern

       
    • Andy Dustman

      Andy Dustman - 2005-06-13

      Try db.commit() after your insert

       
      • bjoernpeters

        bjoernpeters - 2005-06-13

        Thanks for the quick reply - it works fine now.
        Out of curiosity, is the windows / debian difference caused by different default settings for autocommit?

        Thanks again for your support,

        Bjoern

         
        • Andy Dustman

          Andy Dustman - 2005-06-13

          No. You are probably moving from MySQLdb prior to 1.2.0, which did not turn autocommit on or off (used server default). 1.2.0 turns it off, which is what the DB-API requires. That or you have switch table types to a transaction-safe table like InnoDB.

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.