Changes between Version 32 and Version 33 of TracDev/DatabaseApi
- Timestamp:
- Feb 23, 2016, 2:41:02 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/DatabaseApi
v32 v33 159 159 === Configuration 160 160 161 For determiningwhich database has to be used, Trac looks at the value of the {{{database}}} configuration option in [wiki:TracIni trac.ini], which should contain a database connection URI. The default value for this option tells Trac to use an SQLite database inside the environment directory:161 To determine which database has to be used, Trac looks at the value of the {{{database}}} configuration option in [wiki:TracIni trac.ini], which should contain a database connection URI. The default value for this option tells Trac to use an SQLite database inside the environment directory: 162 162 163 163 {{{#!ini … … 200 200 == Rules for DB API Usage 201 201 202 Different DB API modules have different ways to pass parameters to the cursors' {{{execute}}} method, and different ways to access query results. To keep the database API as thin as possible, the Trac team has decided to usea relatively common subset in all database code.202 Different DB API modules have different ways to pass parameters to the cursors' {{{execute}}} method, and different ways to access query results. To keep the database API as thin as possible, Trac uses a relatively common subset in all database code. 203 203 204 204 === Parameter passing … … 246 246 == Guidelines for SQL Statements 247 247 248 As you may know, support for the SQL syntax varies among database systems. At Trac we try to stickto a common subset that is supported by the majority of databases:248 As you may know, support for the SQL syntax varies among database systems. Trac adheres to a common subset that is supported by the majority of databases: 249 249 250 250 - no native `date` or `time` database types; store date and time information in seconds as `int` fields (before 0.12) or better, in microseconds and `int64` fields (since 0.12, mapped by each `trac.db.IDatabaseConnector` to a suitable database specific type) 251 251 - no triggers 252 - you may use views if you feel you need them, but so far we didn't feel the need within Trac itself253 254 For anything not portable (and you really fall quickly in there), you need to use some methods from the connection when building your SQL query (e.g. `db.cast(column, type)`, `db.concat(*params)`, `db.like()`, `db.like_escape()`, `db.quote(param)`, `db.get_last_id(cursor, table, col)`).252 - you may use views if you feel you need them, but this not used within Trac core 253 254 For anything not portable (and you really fall quickly in there), you need to use some methods from the connection when building your SQL query, such as `db.cast(column, type)`, `db.concat(*params)`, `db.like()`, `db.like_escape()`, `db.quote(param)`, `db.get_last_id(cursor, table, col)`. 255 255 256 256 For example: