- TurboGears - Deployment
- TurboGears - Restful Applications
- TurboGears - Pluggable Applications
- TurboGears - Writing Extensions
- TurboGears - Hooks
- TurboGears - Scaffolding
- TurboGears - Using MongoDB
- Authorization & Authentication
- TurboGears - Admin Access
- TurboGears - Pagination
- TurboGears - DataGrid
- TurboGears - Crud Operations
- TurboGears - Creating Models
- TurboGears - Sqlalchemy
- TurboGears - Caching
- TurboGears - Cookies and Sessions
- TurboGears - Flash Messages
- TurboGears - Validation
- TurboGears - Toscawidgets Forms
- TurboGears - URL Hierarchy
- TurboGears - JSON Rendering
- TurboGears - Includes
- Genshi Template Language
- TurboGears - HTTP Methods
- TurboGears - Serving Templates
- TurboGears - Dependencies
- TurboGears - First Program
- TurboGears - Environment
- TurboGears - Overview
- TurboGears - Home
TurboGears Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
TurboGears – SQLAlchemy
Although it is possible to use SQL in TurboGears apppcation to perform CRUD operations on any relational database, it is advisable to use SQLAlchemy, a Python toolkit is a powerful Object Relation Mapper that gives apppcation developers the full power and flexibipty of SQL. In addition to support for SQL based databases through SQLAlchemy, TurboGears also supports MongoDB database though Ming. In this section, the functionapty of SQLAlchemy is discussed.
What is ORM (Object Relational Mapping)?
Most programming language platforms are object oriented. The data in RDBMS servers on the other hand is stored as tables. Object relation mapping is a technique of mapping object parameters to underlying RDBMS table structure. An ORM API provides methods to perform CRUD operations without having to write raw SQL statements.
When a TurboGears project is created using ‘quickstart’ command from gearbox toolkit, SQLAlchemy support is enabled by default by the following configuration settings −
config[ use_sqlalchemy ] = True config[ sqlalchemy.url ] = sqpte:///devdata.db
The ‘quickstarted’ project also creates a models package within it. For example, a ‘Hello’ project will have Hellohellomodel. The following files are created in this package −
__init__.py − This is where the database access is set up. The apppcation’s model objects are imported in this module. It also has a DBSession - a global session manager and also a DeclarativeBase, which is a base class for all the model classes.
auth.py − This is where the models used by the authentication stack are defined. Additional database models are stored in this package, as a separate module, and added in the __init__.py.