sqlobject-discuss Mailing List for SQLObject (Page 399)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ian B. <ia...@co...> - 2003-12-04 16:35:45
|
On Dec 4, 2003, at 9:10 AM, Frank Barknecht wrote: > Hallo, > > getting at the lenght of a result with SQLResult's count() finction > issues a "select count(*) from X". In my PostgreSQL table, this is > quite expensive, and I am wondering, why. Analyzing the query shows, > that no index is used: > => explain SELECT count(*) from normal; > NOTICE: QUERY PLAN: I don't think an index could be used in this instance. You aren't finding specific rows, you are finding how many total rows there are. It's kind of dumb that PostgreSQL can't figure this out more quickly, since it must have internal records of the table's size already calculated. I know MySQL has specific optimizations for this case ("SELECT count(*) FROM blah"). If you figure something out, be sure to get back to us, maybe there's something that can be added to SQLObject to fix this. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-12-04 16:35:08
|
| Sure, as long as it doesn't effect working code it's no big deal -- you | didn't really have to put it in a branch before, either. If you're | using test driven development, then it's expected all the tests won't | pass for a while. Thanks! It's just that I'm so used to have Jim Fulton bitching at me about tests and branches that I got scared about it :) -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Win95 is not a virus; a virus does something. -- unknown source |
From: Ian B. <ia...@co...> - 2003-12-04 16:29:31
|
On Dec 4, 2003, at 7:25 AM, Sidnei da Silva wrote: > I would like to merge the branch where I implemented cascade support > on HEAD. At the same time, I would like to merge the branch where I > implemented Sybase support. There are some issues with 'LIMIT' that I > would like to discuss after the merge (it seems Sybase doesn't support > LIMIT?). Is it OK for me to merge, even if Sybase doesn't pass all > tests right now? Sure, as long as it doesn't effect working code it's no big deal -- you didn't really have to put it in a branch before, either. If you're using test driven development, then it's expected all the tests won't pass for a while. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Frank B. <fb...@fo...> - 2003-12-04 15:10:20
|
Hallo, getting at the lenght of a result with SQLResult's count() finction issues a "select count(*) from X". In my PostgreSQL table, this is quite expensive, and I am wondering, why. Analyzing the query shows, that no index is used: => explain SELECT count(*) from normal; NOTICE: QUERY PLAN: Aggregate (cost=3512.10..3512.10 rows=1 width=0) -> Seq Scan on normal (cost=0.00..3371.28 rows=56328 width=0) My table looks like this with pg_dump: CREATE SEQUENCE "normal_id_seq" start 1 increment 1 maxvalue 9223372036854775807 minvalue 1 cache 1; CREATE TABLE "normal" ( "id" integer DEFAULT nextval('"normal_id_seq"'::text) NOT NULL, "description" text, "format" character varying(16), "artist" character varying(200), "category" character varying(100), "title" character varying(200), "price" double precision, "label" character varying(200), "catalog" character varying(20), "datum" timestamp with time zone, "special" character varying(20), Constraint "normal_pkey" Primary Key ("id") ); ciao -- Frank Barknecht _ ______footils.org__ |
From: Sidnei da S. <si...@aw...> - 2003-12-04 13:31:00
|
Hi, I would like to merge the branch where I implemented cascade support on HEAD. At the same time, I would like to merge the branch where I implemented Sybase support. There are some issues with 'LIMIT' that I would like to discuss after the merge (it seems Sybase doesn't support LIMIT?). Is it OK for me to merge, even if Sybase doesn't pass all tests right now? []'s -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher No wonder Clairol makes so much money selling shampoo. Lather, Rinse, Repeat is an infinite loop! |
From: Scott L. <sle...@in...> - 2003-12-04 02:23:43
|
Brad Bollenbach wrote: > Le dimanche, 30 nov 2003, =E0 22:37 Canada/Eastern, Scott LeFevre a =E9= crit : > > I'm new to Python and have been frustrated by a problem specific > to SQLObject. I want to create my classes in seperate > files/modules and import them into the application that I'm > writing. If I do this and try to use any of the SQLObject based > classes that I've created, I always end up with an AttributeError > > For example, if I try to create a new object with the new method, > I'll get something like. > Traceback (most recent call last): > File "test01.py", line 13, in ? > r =3D ProcReport.new() > File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", > line 883, in new > inst._SO_finishCreate(id) > File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", > line 904, in _SO_finishCreate > id =3D self._connection.queryInsertID(self._table, self._idName= , > AttributeError: 'NoneType' object has no attribute 'queryInsertID' > > Now if I copy the class code in the same file as the applicate > code everything works. I've tried importing my class files via > 'import classfile' and 'from classfile import *' without any succes= s. > > I realize this is a name space issue, but I thought that the 'from > ... import' statement would resolve this. Can anyone shed some > light on this for me? Can I have my classes in a seperate file or > do I have to put everything in a single file for SQLObject? > > > It's not a namespace issue. python is telling you that a NoneType=20 > object doesn't have a method called queryInsertID, and if you notice=20 > in the error message, the object on which that method is called is=20 > self._connection. > > In other words, your connection is a NoneType, which it obviously=20 > shouldn't be. > > In other words, you didn't define __connection__ (or a per class=20 > _connection) in your module full of SQLObject-derived classes. One of=20 > the most recent posts to this list referred to precisely the same=20 > issue (with precisely the same error message.) > Thank you for your help. Since I'm new to Python, I don't have a good=20 grasp of how global variables work and how to use them properly. I've=20 tried the following: Created a ProcReport class based on SQLObject and saved it in a seperate = file. I then imported this file into my test app. Please see below. _ProcReport.py --------------------------------------------------- from SQLObject import * class ProcReport(SQLObject): #db columns/fields sourceorg =3D StringCol(length=3D10, default=3DNone) mrn =3D StringCol(length=3D10, default=3DNone) lastname =3D StringCol(length=3D10, default=3DNone) firstname =3D StringCol(length=3D10, default=3DNone) middlename =3D StringCol(length=3D10, default=3DNone) dateofbirth =3D DateTimeCol(default=3DNone) gender =3D StringCol(length=3D1, default=3DNone) orderingmd =3D StringCol(length=3D20, default=3DNone) procdesc =3D StringCol(length=3D20, default=3DNone) srvdatetime =3D DateTimeCol(default=3DNone) readingmd =3D StringCol(length=3D20, default=3DNone) reporttext =3D StringCol(default=3DNone) reporthtml =3D StringCol(default=3DNone) reportsource =3D StringCol(default=3DNone) ------------------------------------- test01.py ----------------------------------- from SQLObject import * __connection__ =3D MySQLConnection(host=3D'localhost', user=3D'xxxxx', = passwd=3D'zzzz', db=3D'ReportDR') from _ProcReport import ProcReport ProcReport.createTable() --------------------------------- When I run the test01.py app I get the AttributeError: 'NoneType' as I=20 listed in a previous post. My best guess is the __connection__ variable = isn't available when the class is declared. I've tested this by=20 inserting the following code into both files: for k,v in globals().items(): print k,'=3D',v the __connection__ variable doesn't print from the _ProcReport file but=20 does from the test01 file. I hope this is clear. I'm stumped as to why this doesn't work. Could=20 someone please share with me a clean way of accomplishing this? Or, a=20 good example of how to use global variables? Thank you for you help!! --=20 Scott LeFevre, Consultant Solutio Informatio |
From: Sidnei da S. <si...@aw...> - 2003-12-03 22:00:57
|
Howdy, I checked in the work i did to allow 'DELETE CASCADE' and 'DELETE RESTRICT' on a branch named 'cascadegeddon-branch'. I've tested with Postgres and SQLite, and both work fine. Please, check it out and give your feedback :) []'s -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher The only thing cheaper than hardware is talk. |
From: Sidnei da S. <si...@aw...> - 2003-12-03 21:17:14
|
| >First, I'm getting the 'foreign' class via findClass(col.foreignKey), | >without passing the registry parameter, because AFAICT, I can't get to | >the SQLObject class from the column. Is that correct? How much trouble | >can that buy us? :) | | SOCol should get the foreign class, but not during instantiation | (because it's instantiated when the class is created, but the foreign | class may not be instantiated yet). There should be a function that | gets called in SOCol when the foreign class is created, and you should | set up anything you need then. The foreign class is only needed when postgresCreateSQL is called on the column. I can't really see where _registry is set, but it seems to be done on MetaSQLObject. If thats true, would it be fine to set and hold reference to the class on the column? Maybe having the column know the value of the class' _registry would be a better idea to avoid cyclic references? -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher I wish you humans would leave me alone. |
From: Sidnei da S. <si...@aw...> - 2003-12-03 21:02:21
|
So, I've got an improved version of the patch, which should work with the other databases as well, though I didn't tested yet (have to setup mysql at least). Let me summarize what I've understood, and what I implemented to make sure I got it right this time. I'm not a DB master, just a dirty little python hacker ;) 1. If you create a Foreign Key, it is possible in Postgres to create a constraint to 'enforce' that the foreign key exists in the foreign table. It is also possible to specify that you want to 'cascade delete'. This means that when one record is deleted from the foreign table, all records refering to this record in the local table are deleted as well. This is recursive. 2. In the same sense, you may also create a 'restrict delete' constraint, which prevents a record from being deleted from the foreign table until no more records on the local table reference it. 3. If you drop the foreign table, the local table is not affected, no matter how many records reference the foreign table. 4. It is impossible to work around the cascade delete unless you drop the constraint. Does that sound right? Here goes the new patch attached, and off I go, to test with MySQL. []'s -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Not only Guinness - Linux is good for you, too. -- Banzai on IRC |
From: Sidnei da S. <si...@aw...> - 2003-12-03 20:06:38
|
On Wed, Dec 03, 2003 at 01:25:43PM -0600, Ian Bicking wrote: | I haven't looked at the patch in context yet, but a couple comments... | | >Second, I think that as I'm getting the 'dependent'[1] classes via | >findDependencies, It would be simple to pass them into | >DBConnection.dropTable() so that we can do the cascade the manual way | >-- by iterating on the result of select() and calling destroySelf() on | >each object. Does that sound reasonable? | | You mean, delete every instance from the table, then delete the table? | Hmm... dropping a table is a pretty severe thing whatever way you do | it, I'm not sure how important destroySelf is at that point. OTOH, | maybe if you just want to drop without any checks (and presumably | restart your process), you should do it with plain SQL and not the | class method. (E.g., test code will want to do that drop, so it can | start from a consistent state regardless of previous possible | corruption) Ok, I think I misunderstood Postgres here. I though that 'DROP TABLE $tablename CASCADE' would remove the dependant records from the other tables, but that doesn't seem to be true. It changes the dependant tables only when you delete a row, which is good. I didn't had understood that. | >[1] I considered 'dependent' a class that has a column which refers to | >our class on the 'foreignKey' attribute, and also has 'cascade' set to | >True. | | I suppose it follows that if the rows are dependent, the table as a | whole is as well. OTOH, that wouldn't occur to me naturally -- it's | something of a corner case. The principle of least surprise would | indicate that we should leave the table around. But that's no good, as | we're inconsistent at that point. I don't follow you 100% here, but I think its related to the above comment. | And what about circular dependencies? These can only happen if NULL is | also allowed in the foreign key, but it does happen. In this case we'd | want to NULL out the one table, remove the first, then maybe remove the | second. I didn't understood this one as well. -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher People are going to scream bloody murder about that. -- Seen on linux-kernel |
From: Ian B. <ia...@co...> - 2003-12-03 19:25:36
|
I haven't looked at the patch in context yet, but a couple comments... On Dec 3, 2003, at 12:43 PM, Sidnei da Silva wrote: > Ok, attached is my first try. There's two things I would like to > discuss before going on supporting the other databases: > > First, I'm getting the 'foreign' class via findClass(col.foreignKey), > without passing the registry parameter, because AFAICT, I can't get to > the SQLObject class from the column. Is that correct? How much trouble > can that buy us? :) SOCol should get the foreign class, but not during instantiation (because it's instantiated when the class is created, but the foreign class may not be instantiated yet). There should be a function that gets called in SOCol when the foreign class is created, and you should set up anything you need then. > Second, I think that as I'm getting the 'dependent'[1] classes via > findDependencies, It would be simple to pass them into > DBConnection.dropTable() so that we can do the cascade the manual way > -- by iterating on the result of select() and calling destroySelf() on > each object. Does that sound reasonable? You mean, delete every instance from the table, then delete the table? Hmm... dropping a table is a pretty severe thing whatever way you do it, I'm not sure how important destroySelf is at that point. OTOH, maybe if you just want to drop without any checks (and presumably restart your process), you should do it with plain SQL and not the class method. (E.g., test code will want to do that drop, so it can start from a consistent state regardless of previous possible corruption) > [1] I considered 'dependent' a class that has a column which refers to > our class on the 'foreignKey' attribute, and also has 'cascade' set to > True. I suppose it follows that if the rows are dependent, the table as a whole is as well. OTOH, that wouldn't occur to me naturally -- it's something of a corner case. The principle of least surprise would indicate that we should leave the table around. But that's no good, as we're inconsistent at that point. And what about circular dependencies? These can only happen if NULL is also allowed in the foreign key, but it does happen. In this case we'd want to NULL out the one table, remove the first, then maybe remove the second. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-12-03 18:50:09
|
Argh. As usual, I've forgot the attachment. Here it goes. -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Sendmail may be safely run set-user-id to root. -- Eric Allman, "Sendmail Installation Guide" |
From: Sidnei da S. <si...@aw...> - 2003-12-03 18:49:29
|
On Wed, Dec 03, 2003 at 10:28:08AM -0600, Ian Bicking wrote: | On Dec 3, 2003, at 8:59 AM, Sidnei da Silva wrote: | >I just realized that when using ForeignKey, the created table doesn't | >create the foreign key constraints. I would like to add that + the | >'cascade' option to ForeignKey, at least on Postgres. Is there any | >objection on doing so? | | That's fine. It would be nice if MySQL and SQLite could also do | cascades, from the SQL side, i.e., destroySelf() would do the cascade | manually -- at least consider the necessary hooks. Firebird is | probably like Postgres, but I don't know if the syntax matches. Ok, attached is my first try. There's two things I would like to discuss before going on supporting the other databases: First, I'm getting the 'foreign' class via findClass(col.foreignKey), without passing the registry parameter, because AFAICT, I can't get to the SQLObject class from the column. Is that correct? How much trouble can that buy us? :) Second, I think that as I'm getting the 'dependent'[1] classes via findDependencies, It would be simple to pass them into DBConnection.dropTable() so that we can do the cascade the manual way -- by iterating on the result of select() and calling destroySelf() on each object. Does that sound reasonable? [1] I considered 'dependent' a class that has a column which refers to our class on the 'foreignKey' attribute, and also has 'cascade' set to True. Thoughts? -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Counting in binary is just like counting in decimal -- if you are all thumbs. -- Glaser and Way |
From: Ian B. <ia...@co...> - 2003-12-03 16:34:48
|
On Dec 3, 2003, at 9:03 AM, Andrew Barilla wrote: > I'm a fairly new user to SQLObject and Webware but I've got my new > site up and > running. The only thing is that I have set _cacheValues = False in my > SQLObjects so that if I update data, it's reflected on the view-only > part of > the website. Is this the only way to do this or can I force a refresh > of the > cache? I looked through the mailing list archives but couldn't find > anything > definite on this topic. You can force a cache refresh on any instance by calling .refresh(), or .expire() to cause a refresh sometime in the future (when the instance is used again). When you want to expire a whole batch, you'll just run through the objects and do this. DBConnection.Transaction.rollback does this, as a model. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Ian B. <ia...@co...> - 2003-12-03 16:31:34
|
On Dec 3, 2003, at 8:59 AM, Sidnei da Silva wrote: > I just realized that when using ForeignKey, the created table doesn't > create the foreign key constraints. I would like to add that + the > 'cascade' option to ForeignKey, at least on Postgres. Is there any > objection on doing so? That's fine. It would be nice if MySQL and SQLite could also do cascades, from the SQL side, i.e., destroySelf() would do the cascade manually -- at least consider the necessary hooks. Firebird is probably like Postgres, but I don't know if the syntax matches. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-12-03 15:04:47
|
I just realized that when using ForeignKey, the created table doesn't create the foreign key constraints. I would like to add that + the 'cascade' option to ForeignKey, at least on Postgres. Is there any objection on doing so? []'s -- Sidnei da Silva <si...@aw...> http://awkly.org - dreamcatching :: making your dreams come true http://plone.org/about/team#dreamcatcher Recursion is the root of computation since it trades description for time. |
From: Andrew B. <an...@ex...> - 2003-12-03 14:57:44
|
I'm a fairly new user to SQLObject and Webware but I've got my new site up and running. The only thing is that I have set _cacheValues = False in my SQLObjects so that if I update data, it's reflected on the view-only part of the website. Is this the only way to do this or can I force a refresh of the cache? I looked through the mailing list archives but couldn't find anything definite on this topic. Thanks, Andrew |
From: Oisin M. <oi...@en...> - 2003-12-02 15:15:35
|
Hi, Does anyone have problems using SQLObject with MySQL 4.0+ ? I recently installed MySQL 4 on two of my systems (suse and osx). Now I can't get any of my programs to run as they used to under mysql 3.23.+ I've created a python script model of the problem and attached it. When I run this on my Redhat system with mysql 3.23, the program works: 1 - Using MySQLdb: 1 - results: (('mysql',), ('test',)) 2 - Using SQLObject: QueryOne: SELECT COUNT(*) FROM func WHERE name; COUNT results: 0 no results! 2 - results <SQLObject.SQLObject.SelectResults object at 0x91921ec> When I run this on osx and suse using mysql 4+ I get: 1 - Using MySQLdb: 1 - results: (('mysql',), ('test',)) 2 - Using SQLObject: Traceback (most recent call last): File "db.py", line 55, in ? main() File "db.py", line 47, in main if len(results) > 0: TypeError: len() of unsized object I've tried using different versions of SQLObject from 0.3 up to 0.5 with no effect. It appears that mysql 4 is the the problem. Can anyone shed any light on this problem? Redhat Severn: SQLObject 0.5.1 MySQL-python-0.9.2 mysql Ver 11.18 Distrib 3.23.57, for redhat-linux-gnu (i386) Suse 9: SQLObject 0.5.1 MySQL-python-0.9.2 mysql Ver 12.21 Distrib 4.0.15, for suse-linux (i686) OSX 10.3: SQLObject 0.5.1 MySQL-python-0.9.2 mysql Ver 12.22 Distrib 4.0.16, for apple-darwin6.6 (powerpc) Can anyone shed any light on this problem? om -- Oisin Mulvihill Engines Of Creation Email: oi...@en... Work: +353 1 6791602 Mobile: +353 868191540 |
From: Brad B. <br...@bb...> - 2003-12-01 14:30:35
|
Le dimanche, 30 nov 2003, =E0 22:37 Canada/Eastern, Scott LeFevre a = =E9crit=20 : > I'm new to Python and have been frustrated by a problem specific to=20 > SQLObject.=A0 I want to It's not a problem specific to SQLObject. > create my classes in seperate files/modules and import them into the=20= > application that I'm writing.=A0 If I do this and try to use any of = the=20 > SQLObject based classes that I've created, I always end up with an=20 > AttributeError > > For example, if I try to create a new object with the new method, I'll=20= > get something like. > Traceback (most recent call last): > =A0 File "test01.py", line 13, in ? > =A0=A0=A0 r =3D ProcReport.new() > =A0 File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", = line=20 > 883, in new > =A0=A0=A0 inst._SO_finishCreate(id) > =A0 File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", = line=20 > 904, in _SO_finishCreate > =A0=A0=A0 id =3D self._connection.queryInsertID(self._table, = self._idName, > AttributeError: 'NoneType' object has no attribute 'queryInsertID' > > Now if I copy the class code in the same file as the applicate code=20 > everything works.=A0 I've tried importing my class files via 'import=20= > classfile' and 'from classfile import *' without any success. > > I realize this is a name space issue, but I thought that the 'from ...=20= > import' statement would resolve this.=A0 Can anyone shed some light on=20= > this for me?=A0 Can I have my classes in a seperate file or do I have = to=20 > put everything in a single file for SQLObject? It's not a namespace issue. python is telling you that a NoneType=20 object doesn't have a method called queryInsertID, and if you notice in=20= the error message, the object on which that method is called is=20 self._connection. In other words, your connection is a NoneType, which it obviously=20 shouldn't be. In other words, you didn't define __connection__ (or a per class=20 _connection) in your module full of SQLObject-derived classes. One of=20 the most recent posts to this list referred to precisely the same issue=20= (with precisely the same error message.) -- Brad Bollenbach BBnet.ca= |
From: Scott L. <sle...@in...> - 2003-12-01 03:38:01
|
I'm new to Python and have been frustrated by a problem specific to SQLObject. I want to create my classes in seperate files/modules and import them into the application that I'm writing. If I do this and try to use any of the SQLObject based classes that I've created, I always end up with an AttributeError For example, if I try to create a new object with the new method, I'll get something like. Traceback (most recent call last): File "test01.py", line 13, in ? r = ProcReport.new() File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line 883, in new inst._SO_finishCreate(id) File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line 904, in _SO_finishCreate id = self._connection.queryInsertID(self._table, self._idName, AttributeError: 'NoneType' object has no attribute 'queryInsertID' Now if I copy the class code in the same file as the applicate code everything works. I've tried importing my class files via 'import classfile' and 'from classfile import *' without any success. I realize this is a name space issue, but I thought that the 'from ... import' statement would resolve this. Can anyone shed some light on this for me? Can I have my classes in a seperate file or do I have to put everything in a single file for SQLObject? -- Scott LeFevre, Consultant Solutio Informatio |
From: Brad B. <br...@bb...> - 2003-11-28 22:21:30
|
Le vendredi, 28 nov 2003, =E0 17:13 Canada/Eastern, Scott LeFevre a = =E9crit=20 : [ snip ] > _connection_ =3D MySQLConnection(host=3D"localhost", user=3D"xxxx", > passwd=3D"zzzz", db=3D"ReportDR") The special attribute is __connection__, not _connection_. -- Brad Bollenbach BBnet.ca |
From: Scott L. <sle...@in...> - 2003-11-28 22:13:26
|
I'm fairly new to SQLObject and Python for that fact. I've poured over a few python tutorials and actually read the SQLObject docs. I feel brassy enough to try a small program but I'm stuck before get started. Here's what I have installed (all from RPMs): RedHat 9 python 2.3 SQLObject 5.1 MySQL 3.23.58 MySQL-Python Here's the code I put together: from SQLObject import * _connection_ = MySQLConnection(host="localhost", user="xxxx", passwd="zzzz", db="ReportDR") class ProcReport(SQLObject): _table = "procReport" #db columns sourceOrg = StringCol(length=10) mrn = StringCol(length=10) lastName = StringCol(length=10) firstName = StringCol(length=10) middleName = StringCol(length=10) dateOfBirth = DateTimeCol(default=None) gender = StringCol(length=1, default=None) orderingMd = StringCol(length=20) procDesc = StringCol(length=20) srvDateTime = DateTimeCol(default=None) readingMd = StringCol(length=20) reportText = StringCol() reportHtml = StringCol() reportSource = StringCol() #create the table ProcReport.createTable() When I run this, I get Traceback (most recent call last): File "_ProcReport.py", line 33, in ? ProcReport.createTable() File "/usr/lib/python2.3/site-packages/SQLObject/SQLObject.py", line 965, in createTable cls._connection.createTable(cls) AttributeError: 'NoneType' object has no attribute 'createTable' Any ideas? I've even tried to run the people.py example from the 5.1 tarball with the following results: #python2.3 people.py create Traceback (most recent call last): File "people.py", line 96, in ? table.createTable(ifExists=True) TypeError: createTable() got an unexpected keyword argument 'ifExists' And the tutorials made it look so darn easy.... -- ------------------------------------------------------------------------ Scott LeFevre, Consultant Solutio Informatio t: 317/696-1010 |
From: Emanuele O. <oli...@it...> - 2003-11-27 08:45:21
|
On Wed, Nov 26, 2003 at 11:37:59AM -0600, Ian Bicking wrote: > A SQLObject problem I suppose, though it's because you have trivial > classes. The only column in your A and B tables is the ID (which > SQLite generates automatically on insert). So there's no values to > insert, and there's no way to express an insert that doesn't insert > anything (strictly speaking, it inserts an ID, but because it is > implicit it doesn't show up in the SQL, and so the SQL is invalid). OK. I'm just jumping in SQLObject in these days so I try to give feedback as soon as possible. > Add some columns to your classes and you should be okay. They won't be > useful until you do that anyway. For sure. Thanks, Emanuele |
From: Luke O. <lu...@me...> - 2003-11-27 07:36:41
|
Mike - listofpersons (and any return of select()) is a list, not a dictionary keyed by ids. So listofpersons[newid] is almost guaranteed to be out of range (if your database ids start at 1 and list indexes start at 0, then even with no deleted Persons it will be wrong), and even if not out of range probably not the object you wanted. If you want a specific Person, use Person(newid), if you want a list of Persons from select() treat them as a list (ie, iterate through them as you mentioned works, or access by positional index, etc). - Luke Quoting Mike Edmonds <mi...@mi...>: > Can anyone tell me why I get the following error? I am creating a new > object, and then trying to access that object via a newly queried second > object. And getting a list index out of range error. If I simply iterate > through the new list (without referring to the item by index) then it will > appear in the list. If I run a different script with the same code querying > the table I can access it okay. > > > from SQLObject import * > > > class Person(SQLObject): > _connection = MySQLConnection(host='localhost', db='jcpos', > user='test', passwd='') > first_name = StringCol(length=100,default="") > middle_initial = StringCol(length=1, default="") > last_name = StringCol(length=100, default="") > > > newperson = Person.new(first_name="Mike") > newid = newperson.id > > listofpersons = Person.select() > print listofpersons[newid].first_name > > Traceback (most recent call last): > File "D:\dev\pythontest\sqlerror.py", line 18, in ? > print listofpersons[newid].first_name > File "C:\Python23\Lib\site-packages\SQLObject\SQLObject.py", line 1056, in > __g > etitem__ > return list(self.clone(start=value, stop=value+1))[0] > IndexError: list index out of range |
From: Mike E. <mi...@mi...> - 2003-11-27 05:57:27
|
Can anyone tell me why I get the following error? I am creating a new = object, and then trying to access that object via a newly queried second = object. And getting a list index out of range error. If I simply iterate = through the new list (without referring to the item by index) then it = will appear in the list. If I run a different script with the same code = querying the table I can access it okay. from SQLObject import * class Person(SQLObject): _connection =3D MySQLConnection(host=3D'localhost', db=3D'jcpos', user=3D'test', passwd=3D'') first_name =3D StringCol(length=3D100,default=3D"") middle_initial =3D StringCol(length=3D1, default=3D"") last_name =3D StringCol(length=3D100, default=3D"") newperson =3D Person.new(first_name=3D"Mike") newid =3D newperson.id listofpersons =3D Person.select() print listofpersons[newid].first_name Traceback (most recent call last): File "D:\dev\pythontest\sqlerror.py", line 18, in ? print listofpersons[newid].first_name File "C:\Python23\Lib\site-packages\SQLObject\SQLObject.py", line = 1056, in __g etitem__ return list(self.clone(start=3Dvalue, stop=3Dvalue+1))[0] IndexError: list index out of range |