Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 11 and Version 12 of MySql


Ignore:
Timestamp:
01/06/07 14:51:25 (11 years ago)
Author:
jorge.vargas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MySql

    v11 v12  
    1 = MySQL Installation = 
    2 See DataBaseInstallation 
    3  
    4 = Setup the database for TG to work with = 
    5 Firstly need to set DB connection string in ''dev.cfg'' (for development environment, ''prod.cfg'' for production environment) like: 
    6 {{{ 
    7 sqlobject.dburi="mysql://george@localhost/test" 
    8 }}} 
    9  
    10 assuming ''george'' as database username, ''localhost'' as hostname and ''test'' as database name. 
    11  
    12 Then we need to create database using shell: 
    13 {{{ 
    14 $ mysql -h localhost -u root -p menagerie 
    15  
    16 mysql> CREATE DATABASE test; 
    17 Query OK, 1 row affected (0.03 sec) 
    18  
    19 mysql> GRANT ALL ON test.* TO 'george'@'localhost'; 
    20 Query OK, 0 rows affected (0.11 sec) 
    21  
    22 mysql> CTRL+d 
    23 Bye 
    24 }}} 
    25  
    26 Now we can test the DB connection as follows: 
    27  
    28 {{{ 
    29 shell> mysql -h localhost -u george -p test 
    30 Enter password: ENTER 
    31 }}} 
    32  
    33 Now it is everything prepared and we can create database structure using our model: 
    34  
    35 {{{ 
    36 tg-admin sql create 
    37 }}} 
    38  
    39 == To Transaction or Not to Transaction == 
    40  
    41 By default TurboGears uses Transactions (the rest of this page 
    42 applies if you want to use MySQL with Transactions). 
    43  
    44 Kevin has added a hook that allows you to disable transactions 
    45 in TurboGears.  If you do not want TurboGears to manage trancstions 
    46 do this: 
    47  
    48 {{{ 
    49  
    50          
    51 1. Kevin Dangoor 
    52         Dec 29, 11:54 am   show options 
    53 From: Kevin Dangoor <dang...@gmail.com> - Find messages by this author 
    54 Date: Thu, 29 Dec 2005 11:54:25 -0500 
    55 Local: Thurs, Dec 29 2005 11:54 am 
    56 Subject: to the mysql users with rollback exceptions 
    57 Reply | Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse 
    58  
    59 As of r417, if you put notrans_ in front of the DBURI, TurboGears will 
    60 silently ignore all begin/commit/rollback/end instructions. 
    61  
    62 Kevin  
    63 }}} 
    64  
    65  
    66 If you want to use Transactions, read the rest of this page :-) Note that transactions is not the only reason why using InnoDB is a good idea. InnoDB also enforces data integrity much stricter than MyISAM and also has many more features. 
    67  
    68 Question: I tried changing my sqlobject.dburi from "mysql://..." to "notrans_mysql://..." but I found that it didn't work. I'm getting this traceback: 
    69 {{{ 
    70 #!python 
    71 Traceback (most recent call last): 
    72   File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r657-py2.4.egg/turbogears/toolbox/catwalk/__init__.py", line 120, in __init__ 
    73     CatWalkState.createTable(ifNotExists=True) 
    74   File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/main.py", line 1320, in createTable 
    75     if ifNotExists and conn.tableExists(cls.sqlmeta.table): 
    76 AttributeError: 'NoneType' object has no attribute 'tableExists' 
    77 }}} 
    78  
    79  
    80 == Background == 
    81  
    82 when the command: 
    83  
    84 {{{ 
    85  
    86 tg-admin sql create 
    87  
    88 }}} 
    89  
    90  
    91 is issued, the default table type is used. 
    92  
    93  
    94 Mike summerized the options in an excellent email. 
    95  
    96 {{{ 
    97 Mike Stephen 
    98 Dec 17, 5:17 pm   show options 
    99 From: "Mike Stephen" <mike.r.step...@gmail.com> - Find messages by this author 
    100 Date: Sat, 17 Dec 2005 14:17:21 -0800 
    101 Local: Sat, Dec 17 2005 5:17 pm 
    102 Subject: Re: TurboGears, MySQL, Transactions, and InnoDB tables Oh My 
    103  
    104 Hi Mike, 
    105  
    106 I'm using MySQL with turbogears and they're working very nicely 
    107 together for me. What you need to do is to configure MySQL so that it 
    108 uses InnoDB as the default storage engine as Jonathan pointed out, so 
    109 that when you issue a create table statement, it'll be an InnoDB table 
    110 by default. 
    111  
    112 Do you have the MySQL Administrator GUI installed? If so, select 
    113 StartUp Variables from the left pane, then choose the General 
    114 Parameters tab. Down the bottom you'll see a Default Storage section. 
    115 Choose InnoDB from the drop-down. 
    116  
    117 Alternatively, you could add the following line to the [mysqld] section 
    118 of your my.ini file: 
    119  
    120 default-storage-engine=INNODB 
    121  
    122 Regards, 
    123  
    124 Mike.  
    125  
    126 }}} 
     1please see http://docs.turbogears.org/1.0/DatabaseMySQL