|
- #!/usr/bin/python
- # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
-
- from decorators import WSGIMySQL # decoratore ( singleton )
-
- wsgisql = WSGIMySQL()
-
- #
- # esempio minimo di controller WSGI
- #
- @wsgisql.db( 'mywiki', 'shoot' )
- def application( environ, start_response ):
-
- cur = environ['mysql.mywiki.cur']
-
- #
- # esecuzione query
- #
- cur.execute( 'SHOW tables;' )
-
- #
- # recupero record e generazione html
- #
-
- start_response( '200 OK', [('content-type', 'text/html; charset=utf-8')] )
-
- yield "<h1>elenco tabelle presenti nel db mywiki (connessione/db 1)</h1>"
-
- for record in cur.fetchall():
- yield str( record ) + "<br>"
-
- #
- # recupero secondo cursore
- #
-
- cur2 = environ['mysql.shoot.cur']
-
- #
- # esecuzione query
- #
- cur2.execute( 'SHOW tables;' )
-
- #
- # recupero record e generazione html
- #
-
- yield "<h1>elenco tabelle presenti nel db shoot (connessione/db 2)</h1>"
-
- for record in cur2.fetchall():
- yield str( record ) + "<br>"
|