Connecting to an existing database using TurboGears framework - Hallo sahabat Dev-Create, Pada Artikel yang anda baca kali ini dengan judul Connecting to an existing database using TurboGears framework, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan Artikel connection, Artikel existing database, Artikel postgres, Artikel SQLObject, Artikel TurboGears, yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : Connecting to an existing database using TurboGears framework
link : Connecting to an existing database using TurboGears framework

Baca juga


Connecting to an existing database using TurboGears framework

Your application would need a DB connection to access the database. A connection is how you tell SQLObject to locate your database. SQLObject is an object relational mapper, a software layer that maps data stored in a relational database to an object model in an object-oriented programming language. The connection string resembles a URI in the following format:


scheme://[user[:password]@]host[:port]/database[?parameters]
For instance:
postgres://user:pwd@localhost:5432/db


SQLObject provides a debug mechanism, which can be turned on easily by appending ?debug=True to the end of your database URI in the dev.cfg file.

postgres://user:pwd@localhost:5432/db?debug=True
This would publish the query generated onto the console.
..........

Define the existing table Bookmark as a class in model.py:-

class Bookmark(SQLObject):

_fromDatabase = True # the table schema be loaded from the database

BookmarkName = StringCol (dbName="bookmark_name")

ProjectId = IntCol(dbName="project_id")

# dbName is the name of the column in the database, BookmarkName is the name reference in code.

..........
Using the following code in controller.py you should be able to retrieve the second record from the Bookmark table

 
b=Bookmark.select()
print ": %s " % b[2].BookmarkName








Demikianlah Artikel Connecting to an existing database using TurboGears framework

Sekianlah artikel Connecting to an existing database using TurboGears framework kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.

Anda sekarang membaca artikel Connecting to an existing database using TurboGears framework dengan alamat link https://dev-create.blogspot.com/2009/03/connecting-to-existing-database-using.html