sqlobject-discuss Mailing List for SQLObject (Page 380)
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: Ivo v. d. W. <iv...@am...> - 2004-06-15 20:16:15
|
On 15-jun-04, at 16:52, Cary Fitzhugh wrote: > Hey all, > > I'm using SQLObject 0.5 with SQLite and had a problem with multiple > joins. > > The relevant code is: > > class Users(SQLObject): > _connection = conn > name = StringCol(default=None) > email = StringCol(default=None) > password = StringCol() > username = StringCol(alternateID=True) > lastLogin = DateTimeCol(default=None) > user_type = IntCol(default=None) > projects = MultipleJoin('Projects') > > AND: > > class Projects(SQLObject): > _connection = conn > state = IntCol() > number = IntCol(alternateID=True) > creator = ForeignKey('Users') > client = ForeignKey('Clients',notNone=True) > > As far as I could tell in the documentation to connect these two > tables, I just say: > Projects.add(blah blah, creator=Users(1)) > > and then > for a in Users(1).projects: > print a > > should give me something, but it just says that there is no users_id > in the projects table. > Add joinColumn="creator_id' in your MultipleJoin definition. Cheers Ivo |
From: <mic...@ya...> - 2004-06-15 16:25:33
|
Hi guys! I have a problem integrating webware and sqlobject. I think the question is the webware caching, but I don´t know well, look at the code: ############################## from Database import SomeTable from SearchForm import SearchForm class Search(SearchForm): def validateRequest(self): ... self.result=SomeTable.select(SomeTable.q.some_column=='bla') def writeContent(self): for i in self.result: self.writeln('some information...') ############################## The SearchForm is a Form based on a Template, this one based on page... On my template I defined a method "validateRequest", it verifies if there is an error and append the error to a error list, if this error list is true, I show the error... One time I need to check how many rows I get, and a proper time show a error massage in the error case, I need to generate the self.result in the validateRequest method. The problem is that the database changes (every time, outside the webware) and the data shown in the Search are not changed. I have some similar problem in another project, in this case, the database don´t change every time but when I change it by using SomeTable.get(x).set(...), some sectors of the page have the proper data and some sections not. What can I do, please? Thanks for any help :) ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: Cary F. <ckf...@ho...> - 2004-06-15 14:53:11
|
Hey all, I'm using SQLObject 0.5 with SQLite and had a problem with multiple joins. The relevant code is: class Users(SQLObject): _connection = conn name = StringCol(default=None) email = StringCol(default=None) password = StringCol() username = StringCol(alternateID=True) lastLogin = DateTimeCol(default=None) user_type = IntCol(default=None) projects = MultipleJoin('Projects') AND: class Projects(SQLObject): _connection = conn state = IntCol() number = IntCol(alternateID=True) creator = ForeignKey('Users') client = ForeignKey('Clients',notNone=True) As far as I could tell in the documentation to connect these two tables, I just say: Projects.add(blah blah, creator=Users(1)) and then for a in Users(1).projects: print a should give me something, but it just says that there is no users_id in the projects table. I am guessing that there is some flag I am not setting or something I'm not doing that would make that flag get added. Any suggestions? _________________________________________________________________ Get fast, reliable Internet access with MSN 9 Dial-up now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ |
From: Ahmed M. A. <ahm...@wa...> - 2004-06-15 10:52:56
|
Hi, The connection object that you are using is your original connection, the transaction create a new connection,so you must use that one. The Transaction class uses internally this connection.It exposes the same interface than the Connection class itself and uses a delegation mechanism to communicate with the database server.Here's how you can modify your code in order to work with transaction: <begin modified code> trans = WKVTestTable._connection.transaction() for i in xrange(1000): newrec = WKVTestTable(connection=trans,...) --> set the connection argument to be the transaction itself trans.commit() </end modified code> Ahmed MOHAMED ALI "William Volkman" <wkv...@ne...> wrote in message news:108...@ch...... > I've a small program that inserts a couple of thousand rows into > a postgres database. It appears that transaction handling is > not working as I can see intermediate rows in the database > before the program has committed them. I believe that I'm following > the correct sequence of commands: > > conn = connectionForURI("postgres://wkv@localhost/testdb") > class WKVTestTable(SQLObject): > _connection = conn > _table = 'testtable' > > id = IntCol(dbName='testid') > officeid = IntCol(dbName='officeid') > pointid = IntCol(dbName='pointid') > dest = StringCol(length=1, varchar=False, dbName='dest') > origin = StringCol(length=1, varchar=False, dbName='origin') > createdate = DateCol(dbName='createdate', default=func.CURRENT_DATE) > sourcedate = DateCol(dbName='sourcedate', default=None) > > > trans = WKVTestTable._connection.transaction() > > for i in xrange(1000): > newrec = WKVTestTable(...) > trans.commit() > > I did not specify _cacheValues=False as that would seem to only > apply to a multi access environment (perhaps I'm mistaken?) > > I've updated to revision 126 just now and still no joy. Is > autocommit being set on the connection? Postgresql V7.3.4 on > RH 9, psycopg-1.1.11-py2.2_RH9_wkv1 > > Any suggestions? > > Thanks, > William. > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the > one installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 |
From: Ahmed M. A. <ahm...@wa...> - 2004-06-15 08:50:12
|
Hi all, Sorry about this other message.I 'am making a new one because my previous post is not appearing to be sent. I added the maxdb support to sqlobject.This addon reside in the svn trunk. |
From: Ivo v. d. W. <iv...@am...> - 2004-06-15 08:23:55
|
Hi All, I've been working with SQLObject for a while now and I love it. I have some remarks and questions after using it for a while though: Views: For what it's worth - I tried to create an SQLObject on top of a view (in PostgreSQL). This worked nicely for read operations, but updates don't work, partially because SQLObject assumes that Myview.id has a sequence myview_id_seq, while the original sequence is based on a different table on top of which the view is defined. Nothing serious, just something I tried. Perhaps someone has any real purpose for this :) SQL Inheritance: I tried creating a tree-like structure in SQL with a base 'Node' table and derived tables that need to be linked together. SQLObject can't really handle this. Lots of (SQL) ways to work around this, so no real problem, but at that time, my schema would have been more readable (and it would have allowed me to play with SQL inheritance) Inherticance (FAQ): It's not quite clear to me if the section 'How Does Inheritance Work?' in the FAQ relates to SQL Inheritance or to Python inheritance. Simple (single) inheritance in python works fine for me, i.e. class ParentRelation(SQLObject): parent = ForeignKey("Module") priority = IntCol(default=0) class ModuleParentRelation(ParentRelation): child = ForeignKey("Module") ModuleParentRelation.createTable() This creates just a module_parent_relation table, which is what I would expect. However, multiple inheritance (i.e. Mixins) doesn't work - the mixed in attributes just don't get generated in SQL, i.e. class foo: f = StringCol() class bar: b = StringCol() class blah(SQLObject, foo, bar) # or (foo, bar, SQLObject) bl = StringCol() Doesn't do the trick (come to think of it - should I derive foo and bar from SQLObject as well? I should give that a try) SQLBuilder: I'm using SQLBuilder to retrive childs of my nodes (which are ordered), something like: def Modules(self): return Module.select(AND(ModuleParentRelation.q.childID == Module.q.id, ModuleParentRelation.q.parentID == self.id), orderBy="module_parent_relation.priority") Why can't orderBy use the q attribute of the class? I.e. orderBy=ModuleParentRelatio.q.priority? (Or is there another way?) Now I need to lookup the generated tablename, and it looks less readable. Name genration: I noticed that all-caps class names result in a rather weird generated class name. I.e. 'FOO' will result in a class named 'fo_o'. This is most likely completely according to the defined naming scheme, but I wonder if anyone really wants this. All in all, a great tool, I enjoy it alot. Cheers Ivo -- Drs. I.R. van der Wijk -=- Korte Leidsedwarsstraat 12 Amaze Internet Services V.O.F. 1017 RC Amsterdam, NL -=- T +31-20-4688336 F +31-20-4688337 Zope/Plone/Content Management W http://www.amaze.nl E in...@am... Open Source Solutions W http://vanderwijk.info E iv...@am... Consultancy PGP http://vanderwijk.info/pgp |
From: William V. <wkv...@ne...> - 2004-06-14 07:22:17
|
I've a small program that inserts a couple of thousand rows into a postgres database. It appears that transaction handling is not working as I can see intermediate rows in the database before the program has committed them. I believe that I'm following the correct sequence of commands: conn = connectionForURI("postgres://wkv@localhost/testdb") class WKVTestTable(SQLObject): _connection = conn _table = 'testtable' id = IntCol(dbName='testid') officeid = IntCol(dbName='officeid') pointid = IntCol(dbName='pointid') dest = StringCol(length=1, varchar=False, dbName='dest') origin = StringCol(length=1, varchar=False, dbName='origin') createdate = DateCol(dbName='createdate', default=func.CURRENT_DATE) sourcedate = DateCol(dbName='sourcedate', default=None) trans = WKVTestTable._connection.transaction() for i in xrange(1000): newrec = WKVTestTable(...) trans.commit() I did not specify _cacheValues=False as that would seem to only apply to a multi access environment (perhaps I'm mistaken?) I've updated to revision 126 just now and still no joy. Is autocommit being set on the connection? Postgresql V7.3.4 on RH 9, psycopg-1.1.11-py2.2_RH9_wkv1 Any suggestions? Thanks, William. |
From: Daniel B. <da...@cs...> - 2004-06-13 22:30:23
|
I'm playing with today's svn, and the db connection URIs (used with connectForURI) for sqlite don't seem to handle the special memory-resident target, which sqlite calls :memory:. Normally, if you tell sqlite to use a file named :memory:, it will keep the database in memory instead of using a file on disk. This worked fine with the SQLiteConnection(file=':memory:') interface, but the current URI parsing can't handle it (DBConnection._parseURI). Some examples: URI: sqlite:/:memory: _parseURI: user=None password=None host=None path=/:memory: args={} URI: sqlite://:memory: _parseURI: user=None password=None host=:memory: path=/ args={} URI: sqlite:///:memory: _parseURI: user=None password=None host=None path=/:memory: args={} In none of these does the path come out as :memory:. Moreover, the first and third examples should probably be considered correct, since those URIs identify the file /:memory: , and not SQLite's pseudo-thing that indicates the lack of a file. But in the second URI, the parser interprets an identifer after schema:// as the host, and expects the path to follow another '/' (which isn't supplied, in this example). Since hosts have no other meaning in sqlite URIs, maybe accepting a host named :memory: would be an acceptable hack? Here is a (line-broken) `svn diff` of my implementation of this idea. I also removed the addition of an extra leading '/', which DBConnection._parseURI already provides: danb Index: sqlobject/sqlite/sqliteconnection.py =================================================================== --- sqlobject/sqlite/sqliteconnection.py (revision 126) +++ sqlobject/sqlite/sqliteconnection.py (working copy) @@ -21,10 +21,14 @@ DBAPI.__init__(self, **kw) def connectionFromURI(cls, uri): + magic_host = ':memory:' user, password, host, path, args = cls._parseURI(uri) - assert host is None, "SQLite can only be used locally (with a URI like sqlite:///file or sql:/file, not %r)" % uri + assert host in [ None, magic_host ], "SQLite can only be used locally (with a URI like sqlite:///file or sql:/file, not %r), or with the magic host '%s' to specify in-memory use." % (uri, magic_host) assert user is None and password is None, "You may not provide usernames or passwords for SQLite databases" - return cls(filename='/' + path, **args) + if host == magic_host: + assert path == '/', "You may not provide a path with the magic host '%s'" % magic_host + path = host + return cls(filename=path, **args) connectionFromURI = classmethod(connectionFromURI) def _setAutoCommit(self, conn, auto): -- Daniel Brown www.utacm.org www.cs.utexas.edu |
From: Justus P. <ju...@ry...> - 2004-06-13 07:00:12
|
Here's a more complete (I think I got everything) and somewhat tested version of the same patch. This adds connection keyword parameters to all of the class methods in SQLObject. -- Justus |
From: <mic...@ya...> - 2004-06-13 03:17:55
|
Hi again guys! I search through gmane and I can found a message can help me, so I could do something, but I want to know if I do in the correct way, i will show all the code: ######################################### from sqlobject import * conexao='postgres://localhost/teste' class Person(SQLObject): _connection=conexao name=StringCol(length=100) areas=RelatedJoin('Area') def byArea(self, *elements): connection=self._connection in_clause='' for i in elements: in_clause+='%s, ' % i result=connection.queryAll('''\ select p.id from person p inner join area_person x on (x.person_id=p.id) inner join area a on (x.area_id=a.id) where a.id in (%s) group by p.id; ''' % in_clause[:-2]) return IN(self.q.id, [x[0] for x in result]) byArea=classmethod(byArea) class Area(SQLObject): _connection=conexao name=StringCol(length=100) people=RelatedJoin('Person') ######################################### so I can do: [x.id for x in Person.select(Person.byArea(1, 2))] I can return the selected object (but i prefer to run select manually, so I can agregate another conditions) and I can receive the Area instance, but for a test this code is ok I think... Is there another way to run this query? Is this the best way to execute queries, see that I can do, reater than execute a query, execute a function... thanks for the attention and sorry my poor english :) ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: <mic...@ya...> - 2004-06-12 23:22:40
|
Hi guys! First sorry about my 3 identical and consecutive messages, I don't know why but I was not receiving messages and I think the problem is with my email, but the sending was ok :) I read a few days a message talking about random execute of querys on the database. I want to execute some complex join, or a plpgsql function and the return I want to pass to the class (i want to do this in a class method)... I search on the history and didn't found. How can I do this? Example: class Person(SQLObject): _connection=conexao name=StringCol(length=100) areas=RelatedJoin('Area') def byArea(self, *elements): # do something with this query query='''\ select p.* from person p inner join area_person x on (x.person_id=p.id) inner join area a on (x.area_d=a.id) where a.id in %s group by p.id, p.name ''' % tuple(elements)) class Area(SQLObject): _connection=conexao name=StringCol(length=100) people=RelatedJoin('Person') I want to filter all the people in a determined area, I can't do it with normal SQLObject aproach, so the only way I found is this way... I could need to run a plpgsql query in place of the listed, so I wonder how can I run this query :) thanks for all help! ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: Justus P. <ju...@ry...> - 2004-06-12 07:30:37
|
I've been trying to use multiple databases simultaneously within SQLObject and it works pretty well thus far except for the creation and deletion of tables, which don't take a connection parameter. Looking through the code I see that there is a comment "Should these have a connection argument?" If I say pretty please can I get those methods to take a connection parameter? :-) I've attached a completely untested patch that does this. -- Justus |
From: Andy T. <an...@ha...> - 2004-06-10 16:14:13
|
Peter Gebauer wrote: >>is anybody even interested in using SQLObject with DB2? > > > We're upgrading our IBM DB2 8.1 database to PostgreSQL 7.4, but the old > system is still running DB2. It's unfortunate that we run DB2 at all (I'm > very unhappy with it) and one of the more painful things is the lack of good > DB2 Python support. > It would be most welcome to have a nice Python interface to DB2 since we are > hacking PERL at the moment. > > /Peter > > There is a Python module for DB2 at http://sourceforge.net/projects/pydb2/ You might also want to look at mxODBC (http://www.egenix.com/files/python/mxODBC.html) it works with DB2 UDB but does require a commercial license if you are using it for anything other than personal use. Regards, Andy -- -------------------------------------------------------------------------------- From the desk of Andrew J Todd esq - http://www.halfcooked.com/ |
From: Lars H. <sql...@qu...> - 2004-06-10 14:27:43
|
Hi all, SQLite supports databases in memory (with :memory: as 'filename'). Is it possible to use this feature with SQLObject? Thanks, Lars |
From: Jean-Philippe Barrette-L. <jpb...@sa...> - 2004-06-08 19:02:58
|
On June 8, 2004 02:39 pm, Jean-Philippe Barrette-LaPierre wrote: > I modified SQLObject to be able to use pgPySQL. here's the patch. If you > don't like it, just tell me what's wrong and I'll change it to fullfill > your needs. sorry... forgot to attach the file. -- Jean-Philippe Barrette-LaPierre Maintener of curlpp |
From: Jean-Philippe Barrette-L. <jpb...@sa...> - 2004-06-08 18:41:02
|
I modified SQLObject to be able to use pgPySQL. here's the patch. If you don't like it, just tell me what's wrong and I'll change it to fullfill your needs. -- Jean-Philippe Barrette-LaPierre Maintener of curlpp |
From: William V. <wkv...@ne...> - 2004-06-08 03:27:31
|
After not finding a tool to create the python classes from a Postgres database I decided to write one (a DBA centric approach to development, they define the what, the programmer builds interfaces). I find that the "time" data type is missing (The "DateCol" is there which should be added to the Docs). I also note that the 6.0 docs mention the consideration of multi field primary keys which I'm hoping gets implemented. As a data point the schema I'm working with has 120 tables, only 6 meet the requirement of an single integer primary key field. I've wrangled the DBA into adding two more however he's very much against adding it to the table that gets the most use. So for now I'm hand wrapping some tables, it certainly would be nice to use SQLObject instead. Thanks, William. |
From: <mic...@ya...> - 2004-06-05 02:07:02
|
Hi guys! I want some help with this join: class Person(SQLObject): name=StringCol(length=100) specific_areas=RelatedJoin('SpecificArea') class GeneralArea(SQLObject): name=StringCol(length=50) specific_areas=MultipleJoin('SpecificArea') class SpecificArea(SQLObject): name=StringCol(length=50) general_area=ForeignKey('GeneralArea') people=RelatedJoin('Person') I want to use some join like this: select * from person p inner join person_specific_area x on p.id=x.person_id inner join specific_area s on s.id=x.specific_area_id inner join gereral_area g on s.general_area_id=g.id; I don´t try it, but I think the join it´s the above, I want to add some restrictions on it: 'where s.id=someid' (I want to filter people by his specific_areas). I can use the IN() function of the SQLBuilder, but I can´t create the join with the 2 tables, I don´t know what may I pass to Person.select()... thanks for all help and sorry about my poor english! ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: <mic...@ya...> - 2004-06-02 14:44:35
|
Hi guys! I want some help with this join: class Person(SQLObject): name=StringCol(length=100) specific_areas=RelatedJoin('SpecificArea') class GeneralArea(SQLObject): name=StringCol(length=50) specific_areas=MultipleJoin('SpecificArea') class SpecificArea(SQLObject): name=StringCol(length=50) general_area=ForeignKey('GeneralArea') people=RelatedJoin('Person') I want to use some join like this: select * from person p inner join person_specific_area x on p.id=x.person_id inner join specific_area s on s.id=x.specific_area_id inner join gereral_area g on s.general_area_id=g.id; I don´t try it, but I think the join it´s the above, I want to add some restrictions on it: 'where s.id=someid' (I want to filter people by his specific_areas). I can use the IN() function of the SQLBuilder, but I can´t create the join with the 2 tables, I don´t know what may I pass to Person.select()... thanks for all help and sorry about my poor english! ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: Neil Blakey-M. <nb...@mi...> - 2004-06-02 13:24:59
|
On Wed 2004-06-02 (15:15), Philippe Normand wrote: > > a = sql.table.acct > > if start_date: > > criteria.append(a.stamp_inserted >= start_date) > > if end_date: > > criteria.append(a.stamp_inserted < end_date) > > > > But it doesn't change the problem, too many objects are fetched from the db. > Or am I missing something ? > > I'd like to compare dates directly in select() and not in select() results. > Following your code snippet, I'll try something like: > > table.select((Table.q.stamp_inserted >= start_date) & > (Table.q.stamp_inserted < end_date)) Sorry, I tend to build up a criteria list, and go: table.select(AND(*criteria)) So yes, it will work for select queries just fine. Just mind the bug if seconds are at all important to you. Neil -- Neil Blakey-Milner nb...@mi... http://mithrandr.moria.org/ |
From: Philippe N. <sw...@fr...> - 2004-06-02 13:18:34
|
On Wed, Jun 02, 2004 at 02:13:58PM +0200, Neil Blakey-Milner wrote: > > > > > > it isn't really efficient because it fetches all articles. Is there a clean > > way to select SQLObjects given a specific date interval on DateTimeCol ? > > I just compare them to a datetime, and that works just fine for me. > Although, there's a bug where the datetime conversion uses '%s' instead > of '%S' for seconds, which probably wouldn't affect your usage. > > a = sql.table.acct > if start_date: > criteria.append(a.stamp_inserted >= start_date) > if end_date: > criteria.append(a.stamp_inserted < end_date) > But it doesn't change the problem, too many objects are fetched from the db. Or am I missing something ? I'd like to compare dates directly in select() and not in select() results. Following your code snippet, I'll try something like: table.select((Table.q.stamp_inserted >= start_date) & (Table.q.stamp_inserted < end_date)) Cheers, Philippe |
From: Neil Blakey-M. <nb...@mi...> - 2004-06-02 12:14:17
|
On Wed 2004-06-02 (14:05), Philippe Normand wrote: > I see one durty solution which would like this (untested) : > > calendar = {} # keys: day numbers of the month > for article in Article.select(orderBy=Article.q.date): > if article.getYear() != 2004 or article.getMonth() != 5: > continue > try: > calendar[article.getDay()] += 1 > except KeyError: > calendar[article.getDay()] = 1 > > > it isn't really efficient because it fetches all articles. Is there a clean > way to select SQLObjects given a specific date interval on DateTimeCol ? I just compare them to a datetime, and that works just fine for me. Although, there's a bug where the datetime conversion uses '%s' instead of '%S' for seconds, which probably wouldn't affect your usage. a = sql.table.acct if start_date: criteria.append(a.stamp_inserted >= start_date) if end_date: criteria.append(a.stamp_inserted < end_date) Neil -- Neil Blakey-Milner nb...@mi... http://mithrandr.moria.org/ |
From: Philippe N. <sw...@fr...> - 2004-06-02 12:08:23
|
Hi, I need to sort and count SQLObjects per date. An example might really show what I want :) class Article(SQLObject): date = DateTimeCol() ... I have many many Articles, and I'd like to build a Calendar showing how many articles were published by month and/or year. For instance: 10 articles on 05/22 3 articles on 05/14 I see one durty solution which would like this (untested) : calendar = {} # keys: day numbers of the month for article in Article.select(orderBy=Article.q.date): if article.getYear() != 2004 or article.getMonth() != 5: continue try: calendar[article.getDay()] += 1 except KeyError: calendar[article.getDay()] = 1 it isn't really efficient because it fetches all articles. Is there a clean way to select SQLObjects given a specific date interval on DateTimeCol ? Philippe |
From: <mic...@ya...> - 2004-06-01 16:37:30
|
Hi guys! I want some help with this join: class Person(SQLObject): name=StringCol(length=100) specific_areas=RelatedJoin('SpecificArea') class GeneralArea(SQLObject): name=StringCol(length=50) specific_areas=MultipleJoin('SpecificArea') class SpecificArea(SQLObject): name=StringCol(length=50) general_area=ForeignKey('GeneralArea') people=RelatedJoin('Person') I want to use some join like this: select * from person p inner join person_specific_area x on p.id=x.person_id inner join specific_area s on s.id=x.specific_area_id inner join gereral_area g on s.general_area_id=g.id; I don´t try it, but I think the join it´s the above, I want to add some restrictions on it: 'where s.id=someid' (I want to filter people by his specific_areas). I can use the IN() function of the SQLBuilder, but I can´t create the join with the 2 tables, I don´t know what may I pass to Person.select()... thanks for all help and sorry about my poor english! ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Participe da pesquisa global sobre o Yahoo! Mail: http://br.surveys.yahoo.com/global_mail_survey_br |
From: Scott R. <sc...@to...> - 2004-05-31 15:59:02
|
I hope there's some easy way to make that stop. :) |