| | |
Retrive table from postgresql and display it using python turbogears
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2009
Posts: 12
Reputation:
Solved Threads: 0
hi ,
i just started working in python , am using postgresql connected using turbo gears , python .
I have connected to DB modifying the dev.py ,
I want to display a created table from postgre sql in web browser using python turbo gears ,
my table in the DB is product_category
i have created product_category.kid with following code
And controllers.py is
with model.py as follows,
when i run the code in cmd prompt tg-admin start-project.py
connecting to browser i have the following error :
its been a day am trying to sort out . please any one can guide me out .
Thank you !
i just started working in python , am using postgresql connected using turbo gears , python .
I have connected to DB modifying the dev.py ,
I want to display a created table from postgre sql in web browser using python turbo gears ,
my table in the DB is product_category
i have created product_category.kid with following code
Python Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="master.kid"> <head> <title>Product Category: ${product_category.name}</title> </head> <body> <table id="product-info"> <tr> <td class="fld">Name:</td> <td class="val"><span py:replace="product_category.name" /></td> </tr> <tr> <td class="fld">ID</td> <td class="val"><span py:replace="product_category.id" /></td> </tr> </table> </body> </html>
And controllers.py is
Python Syntax (Toggle Plain Text)
import turbogears as tg from turbogears import controllers, expose class Root(controllers.Root): @expose("project2.templates.product_category") def index(self): from model import Product_Category product_category = Product_Category.selectBy(parent=None)[0] return dict(product_category=product_category) @expose("project2.templates.product_category") def product_category(self, product_categoryID): from model import Product_Category product_category = Product_Category.get(product_categoryID) return dict(product_category=product_category)
Python Syntax (Toggle Plain Text)
import pkg_resources pkg_resources.require("SQLObject>=0.10.1") from turbogears.database import PackageHub # import some basic SQLObject classes for declaring the data model # (see http://www.sqlobject.org/SQLObject.html#declaring-the-class) from sqlobject import SQLObject, SQLObjectNotFound, RelatedJoin # import some datatypes for table columns from SQLObject # (see http://www.sqlobject.org/SQLObject.html#column-types for more) from sqlobject import StringCol, UnicodeCol, IntCol, DateTimeCol from sqlobject import ForeignKey, UnicodeCol, IntCol, DateTimeCol from sqlobject import MultipleJoin, UnicodeCol, IntCol, DateTimeCol from sqlobject import CurrencyCol, UnicodeCol, IntCol, DateTimeCol __connection__ = hub = PackageHub('project2') class Product_Category(SQLObject): name = StringCol(length=64) parent_id = IntCol(default=None)
when i run the code in cmd prompt tg-admin start-project.py
connecting to browser i have the following error :
Python Syntax (Toggle Plain Text)
ProgrammingError: relation "product__category" does not exist
its been a day am trying to sort out . please any one can guide me out .
Thank you !
Last edited by goldy736; Aug 29th, 2009 at 9:14 am.
![]() |
Similar Threads
- Starting Python (Python)
- display:block to show a table? (JavaScript / DHTML / AJAX)
- Display Python code on Blogspot (Python)
- display the data into listbox (PHP)
- How to make an MySQL Table Jion and Display it in JSP (JSP)
- Retrive table then update it (PHP)
- Display morethan one coulmn from mysql database in PHP (PHP)
- How to pass a whole table to another form? (Visual Basic 4 / 5 / 6)
- Refresh Form to Display changes (MySQL)
Other Threads in the Python Forum
- Previous Thread: Which Day of the Week was my Birthday?
- Next Thread: problem : first eve encounter with python
| Thread Tools | Search this Thread |
address aliased anydbm app bash beginner bits changecolor cipher class clear conversion coordinates corners cturtle curves definedlines development dictionary dynamic events examples excel external feet file float format ftp function gui handling homework iframe images import info input java keycontrol line linux list lists loan loop matching mouse number numbers output parsing path permissions port prime programming projects py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang singleton split string strings table tails terminal text thread threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable whileloop windows word wx.wizard wxpython xlwt





