> For me, hub.commit() worked fine for adding a new record. I had
> debug=1 on my dburi and I saw the INSERT happen, and the COMMIT happen
> on the same connection.
>
> If you look at "hub" in your shell, you'll find that it's a
> PackageHub. When you do hub.commit, you're actually talking to the
> AutoConnectHub that's responsible for doing the work (PackageHub has a
> __getattr__ that delegates to the AutoConnectHub underneath).
>
> > So, this may be related to my other problem, which is that on my
> > Ubuntu Laptop I can't use notrans_ to connect to a mysql database,
> > because it is not getting stripped off. (Ticket #346).
>
> Make sure that "hub", when displayed in the shell, is in fact a PackageHub.
It is definitely seems to be. Help(hub) shows PackageHub information....
> Just to confirm something else: you are running tg-admin shell from
> the top level directory of your project, right?
Absolutely. Anything else causes problems ;)
> It's worth making sure
> that the config that's coming through is the one that's desired. You
> can always run cherrypy.config.get() statements to see if
> sqlobject.dburi is what you'd expect.
I've attached the output of an interactive session where I get the
dburi from cherrypy.config.get and try some database connection stuff.
For some reason that I can't quite figure out the ?debug=true link
seems to work here, where it did not on my computer at home. I'll
check into that later tonight.
--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog
C:\TURBOG~1\LINK-K~1>tg-admin shell
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import cherrypy
>>> cherrypy.config.get("sqlobject.dburi")
'sqlite:///c|/turbogears/Link-Keeper/book.db?debug=1'
>>> b=Bookmarks.select()
>>> for a in b:
... print a.link
...
1/Select : SELECT bookmarks.id, bookmarks.name, bookmarks.link,
bookmarks.description FROM bookmarks WHERE 1 = 1
1/QueryR : SELECT bookmarks.id, bookmarks.name, bookmarks.link,
bookmarks.description FROM bookmarks WHERE 1 = 1
http://compoundthinking.com/blog
http://google.com
http://www.turbogears.org
>>> Bookmarks(name="1", link="http://one.com", description="random link")
1/QueryIns: INSERT INTO bookmarks (link, description, name) VALUES
('http://one.com', 'random link', '1')
1/QueryOne: SELECT name, link, description FROM bookmarks WHERE id = 4
1/QueryR : SELECT name, link, description FROM bookmarks WHERE id = 4
<Bookmarks 4 name='1' link='http://one.com' description='random link'>
>>> hub.commit
<bound method AutoConnectHub.commit of <turbogears.database.AutoConnectHub
object at 0x012BABF0>>
>>> ^Z
C:\TURBOG~1\LINK-K~1>tg-admin shell
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> b=Bookmarks.select()
>>> for a in b:
... print a.link
...
1/Select : SELECT bookmarks.id, bookmarks.name, bookmarks.link,
bookmarks.description FROM bookmarks WHERE 1 = 1
1/QueryR : SELECT bookmarks.id, bookmarks.name, bookmarks.link,
bookmarks.description FROM bookmarks WHERE 1 = 1
http://compoundthinking.com/blog
http://google.com
http://www.turbogears.org
>>>