sqlobject-discuss Mailing List for SQLObject (Page 19)
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: Oleg B. <ph...@ph...> - 2012-05-31 14:16:55
|
Ok, found the problem - str() removes one level of backslashes so I have to double backslashes once again. See the attached patch - it passes all tests. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2012-05-31 10:01:30
|
On Thu, May 31, 2012 at 11:35:31AM +0200, Tom Coetser <su...@ic...> wrote: > On Thursday 31 May 2012 10:57:11 Oleg Broytman wrote: > > On Thu, May 31, 2012 at 11:44:05AM +0400, Oleg Broytman <ph...@ph...> > wrote: > > > Can you apply and test the attached patch? > > > > Please be warned - the patch causes failures of test_blob, > > test_picklecol and test_validation. Seems I have to investigate it > > deeper. > > Thanks for letting me know. So far unit tests on my app seems to be OK with > the patch, but I'll wait to hear more from your side before I deploy the > change. I use utf-8 encoding, and SQLObject tests generates binary data. The reason for failures is that the patch makes SQLObject produce invalid utf-8 sequences. If your databases and client/server encoding is ascii or latin1 - I think the patch is ok. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2012-05-31 09:35:51
|
Hi Oleg, On Thursday 31 May 2012 10:57:11 Oleg Broytman wrote: > On Thu, May 31, 2012 at 11:44:05AM +0400, Oleg Broytman <ph...@ph...> wrote: > > Can you apply and test the attached patch? > > Please be warned - the patch causes failures of test_blob, > test_picklecol and test_validation. Seems I have to investigate it > deeper. Thanks for letting me know. So far unit tests on my app seems to be OK with the patch, but I'll wait to hear more from your side before I deploy the change. Thanks, Tom |
From: Oleg B. <ph...@ph...> - 2012-05-31 08:57:22
|
On Thu, May 31, 2012 at 11:44:05AM +0400, Oleg Broytman <ph...@ph...> wrote: > Can you apply and test the attached patch? Please be warned - the patch causes failures of test_blob, test_picklecol and test_validation. Seems I have to investigate it deeper. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2012-05-31 08:43:25
|
On Thu, May 31, 2012 at 10:31:33AM +0200, Tom Coetser <su...@ic...> wrote: > Thanks, seems to solve the problem nicely. I assume this will go into the next > release for 1.3, correct? It will go to the repository today, but formal releases will be much later. I'll be on vacation (and completely off-line) until June 20. > > > Any help on how to solve this so I can get my log files cleaned up, in > > > order to debug another connection problem, would be greatly appreciated. > > > > What log files? /var/log/postgresql/*.log? > > Yes, but specifically /var/log/postgresql/postgresql-8.4-main.log on Debian > Squeeze. /etc/init.d/postgresql stop rm /var/log/postgresql/* # or rm *.gz && gzip *.log /etc/init.d/postgresql start Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2012-05-31 08:31:53
|
Hi Oleg, Thanks for the quick reply. On Thursday 31 May 2012 09:44:05 Oleg Broytman wrote: > Hello! > > On Thu, May 31, 2012 at 08:08:42AM +0200, Tom Coetser <su...@ic...> wrote: > > I am getting a warning in the Postgres log for every time a PickleCol is > > written to the database. Since my app uses a pickled col extensively in > > one of the more frequently used tables, the Postgres logs are filled > > with these warnings: > > > > ---------------------- > > WARNING: nonstandard use of \\ in a string literal at character 50 > > HINT: Use the escape string syntax for backslashes, e.g., E'\\'. > > ---------------------- > > Thank you for an example of a good bug report! An error message and a > short test case - exactly what I need. > Can you apply and test the attached patch? Thanks, seems to solve the problem nicely. I assume this will go into the next release for 1.3, correct? > > Any help on how to solve this so I can get my log files cleaned up, in > > order to debug another connection problem, would be greatly appreciated. > > What log files? /var/log/postgresql/*.log? Yes, but specifically /var/log/postgresql/postgresql-8.4-main.log on Debian Squeeze. Again, thanks for the quick reply and fix. Much appreciated. /Tom |
From: Oleg B. <ph...@ph...> - 2012-05-31 07:44:15
|
Hello! On Thu, May 31, 2012 at 08:08:42AM +0200, Tom Coetser <su...@ic...> wrote: > I am getting a warning in the Postgres log for every time a PickleCol is > written to the database. Since my app uses a pickled col extensively in one of > the more frequently used tables, the Postgres logs are filled with these > warnings: > > ---------------------- > WARNING: nonstandard use of \\ in a string literal at character 50 > HINT: Use the escape string syntax for backslashes, e.g., E'\\'. > ---------------------- Thank you for an example of a good bug report! An error message and a short test case - exactly what I need. Can you apply and test the attached patch? > Any help on how to solve this so I can get my log files cleaned up, in order > to debug another connection problem, would be greatly appreciated. What log files? /var/log/postgresql/*.log? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2012-05-31 06:24:17
|
Hi all, I am getting a warning in the Postgres log for every time a PickleCol is written to the database. Since my app uses a pickled col extensively in one of the more frequently used tables, the Postgres logs are filled with these warnings: ---------------------- WARNING: nonstandard use of \\ in a string literal at character 50 HINT: Use the escape string syntax for backslashes, e.g., E'\\'. ---------------------- This is with SQLObject v1.3.0, but it has been there from at least v0.12.4 from which I am upgrading to 1.3.0 now. PostgresSQL is v8.4.11 on Debian Squeeze. An example test case to illustrate the problem is inline below. Any help on how to solve this so I can get my log files cleaned up, in order to debug another connection problem, would be greatly appreciated. Thanks, Tom ------------------------------- from sqlobject import * db = dict(user='tomc', passw='', host='', dbname='tomc') dbURI = "postgres://%(user)s:%(passw)s@%(host)s/%(dbname)s" % db connection = connectionForURI(dbURI) sqlhub.processConnection = connection # Default pickled data - try to use as many object types as possible for tests defaultConfig = dict(ports=2, remote=False, logger=None, services=['web', 'database'], dns=dict(hostname=None, domain='foo.bar') ) # Define the sampe table with a pickled column class Server(SQLObject): name = StringCol() config = PickleCol(notNull=True, default=defaultConfig) # Drop and create table Server.dropTable(ifExists=True) Server.createTable() # Turn on SQLObejct debugging connection.debug=True # Add test records while tailing the postgresql log files s1 = Server(name='foo') ------------------------------- |
From: Oleg B. <ph...@ph...> - 2012-05-25 20:04:16
|
Hello! I'm pleased to announce version 1.3.1, the first bug-fix release of branch 1.3 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://pypi.python.org/pypi/SQLObject/1.3.1 News and changes: http://sqlobject.org/News.html What's New ========== * Fixed a minor bug in PostgreSQL introspection: VIEWs don't have PRIMARY KEYs - use sqlmeta.idName as the key. * Fixed a bug in cache handling while unpickling. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2012-05-25 19:59:25
|
Hello! I'm pleased to announce version 1.2.3, a bugfix release of branch 1.2 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://pypi.python.org/pypi/SQLObject/1.2.3 News and changes: http://sqlobject.org/News.html What's New ========== * Fixed a minor bug in PostgreSQL introspection: VIEWs don't have PRIMARY KEYs - use sqlmeta.idName as the key. * Fixed a bug in cache handling while unpickling. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2012-04-18 20:51:16
|
> > > Ah. Thanks for the tip. > I will look into it; obviously, I would prefer the solution to > be engine independent, but this feature might be more valuable :-) > > As usually, some good search engine (Google??? :D ) is your friend.... IMHO you have to always know which SQL engine is on the on the other side (in other words you have to know how to set up the connection string). If you know the engine, you can decide which kind of SQL "slang" to use: http://www.petefreitag.com/item/466.cfm Petr |
From: Hans G. S. <geo...@sc...> - 2012-04-18 20:14:56
|
On Wed, Apr 18, 2012 at 09:43:23PM +0200, Petr Jakeš wrote: > > Although this might work in the particular application, but > > it is hardly ideal to make two queries, nor to load a long list > > of IDs. Is there a way to do it with a single query? > > > > 1) > Is your task really "time critical"? In my case, yes; it is number crunching. Question should be «is it /that/ "time critical"» :-) I have had some difficulties with slow operations due to multiple queries, and it feels more satisfactory get rid of any avoidable query, even if the saving is only a fraction of a percent of the total running time. > How many records (IDs) do you expect to be returned using the first select? thousands in current tests; hundreds of thousands is likely in future tests, and millions is plausible. > How many kb will it take? Is the list size a real problem for your Internet > connection? Might be; especially when it is over the Internet as opposed to over a LAN. Yet, I am as concerned with query processing time than transmission time. > How often do you expect to release the select querry? Could vary. About 50 clients querying once a minute each may be typical, but I am sure I will see faster jobs completing in seconds, in which case each client would query correspondingly often. > 2) > what is your target database engine? postgres at the moment. > some databases allow "rand" in the select query. > see: > http://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql Ah. Thanks for the tip. I will look into it; obviously, I would prefer the solution to be engine independent, but this feature might be more valuable :-) :-- George > > Petr -- :-- Hans Georg |
From: Petr J. <pet...@tp...> - 2012-04-18 19:43:34
|
> Although this might work in the particular application, but > it is hardly ideal to make two queries, nor to load a long list > of IDs. Is there a way to do it with a single query? > > 1) Is your task really "time critical"? How many records (IDs) do you expect to be returned using the first select? How many kb will it take? Is the list size a real problem for your Internet connection? How often do you expect to release the select querry? 2) what is your target database engine? some databases allow "rand" in the select query. see: http://stackoverflow.com/questions/19412/how-to-request-a-random-row-in-sql Petr |
From: Hans G. S. <geo...@sc...> - 2012-04-18 19:23:27
|
On Wed, Apr 18, 2012 at 08:46:47PM +0200, Petr Jakeš wrote: > *Get the list of valid IDs from the remote database using the raw SQL > command > something like:* > > con = connectionForURI("firebird://yourUserName:yourPassword@serverAddress > :3050/pat/to/database/database.file") > > validIDs= "SELECT ID FROM SONGS_TABLE where ......" > > returnedIDs = con.queryAll(validIDs) > > # you get the list of valid IDs, something like this: [(1,), (2,), (3,), > (4,), (5,), (6,), (7,), (8,), (9,), (11,)] > > *than:* > > import random > randomID = random.choice(returnedIDs)[0] > randomSong = SongsTable.get(randomID) Although this might work in the particular application, but it is hardly ideal to make two queries, nor to load a long list of IDs. Is there a way to do it with a single query? -- :-- Hans Georg |
From: Pʀoмᴇтнᴇυs 0. <pro...@gm...> - 2012-04-18 19:15:27
|
I'll see about adding a recipe to the SQLObject Community Doc site for this. ( https://sites.google.com/site/sqlobject/ ) On Wed, Apr 18, 2012 at 12:46 PM, Petr Jakeš <pet...@tp...> wrote: > > To give context to the issue, I am building my own icecast2 broadcaster. I >> want >> to have an Auto DJ feature which will pick a random song from the >> database which >> hasn't recently been played plus some other criteria. It really doesn't >> matter >> which record i get back from the database, I just need one at random. >> > > *Get the list of valid IDs from the remote database using the raw SQL > command > something like:* > > con = connectionForURI("firebird://yourUserName:yourPassword@serverAddress > :3050/pat/to/database/database.file") > > validIDs= "SELECT ID FROM SONGS_TABLE where ......" > > returnedIDs = con.queryAll(validIDs) > > # you get the list of valid IDs, something like this: [(1,), (2,), (3,), > (4,), (5,), (6,), (7,), (8,), (9,), (11,)] > > *than:* > > import random > randomID = random.choice(returnedIDs)[0] > randomSong = SongsTable.get(randomID) > > HTH > > Regards > > Petr > > > ------------------------------------------------------------------------------ > Better than sec? Nothing is better than sec when it comes to > monitoring Big Data applications. Try Boundary one-second > resolution app monitoring today. Free. > http://p.sf.net/sfu/Boundary-dev2dev > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > > |
From: Petr J. <pet...@tp...> - 2012-04-18 18:46:57
|
> To give context to the issue, I am building my own icecast2 broadcaster. I > want > to have an Auto DJ feature which will pick a random song from the database > which > hasn't recently been played plus some other criteria. It really doesn't > matter > which record i get back from the database, I just need one at random. > *Get the list of valid IDs from the remote database using the raw SQL command something like:* con = connectionForURI("firebird://yourUserName:yourPassword@serverAddress :3050/pat/to/database/database.file") validIDs= "SELECT ID FROM SONGS_TABLE where ......" returnedIDs = con.queryAll(validIDs) # you get the list of valid IDs, something like this: [(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (11,)] *than:* import random randomID = random.choice(returnedIDs)[0] randomSong = SongsTable.get(randomID) HTH Regards Petr |
From: Oleg B. <ph...@ph...> - 2012-04-18 18:31:57
|
On Wed, Apr 18, 2012 at 05:18:41PM +0000, Adam Berg <ada...@gm...> wrote: > Oleg Broytman <phd <at> phdru.name> writes: > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg <adamberg <at> gmail.com> > wrote: > > > What is the best way to select a single random record from a table and > > > falls within the "where" criteria i have defined? I don't want to return a > > > huge result set each time and then pick a random one > > > > Please define "random" in the context of your task. Do you want a > > different record every time? Or some non-deterministic record that could > > be the same every time is a possible solution? > > It should be a different record each time. Do it in two steps. First, count the number of objects that satisfy your criteria: count = MyTable.select(whereClause).count() Optimize your whereClause and indices. Generate an int in range 0..count-1 (see module `random`). And select the item: row = MyTable.select(whereClause, orderBy=MyTable.q.id)[random_int] With this query SQLObject uses OFFSET and LIMIT=1 to select exactly that row. > To give context to the issue, I am building my own icecast2 broadcaster. I want > to have an Auto DJ feature which will pick a random song from the database which > hasn't recently been played plus some other criteria. It really doesn't matter > which record i get back from the database, I just need one at random. Aha, you mark played songs in the DB, so your whereClause certainly contains "if was not played yet" criteria. In this case selecting just the first item without ordering the result set ought to be enough: row = MyTable.select(whereClause)[0] You have to experiment. Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Adam B. <ada...@gm...> - 2012-04-18 17:44:56
|
Adam Berg <adamberg <at> gmail.com> writes: > > Oleg Broytman <phd <at> phdru.name> writes: > > > > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg <adamberg <at> gmail.com> > wrote: > > > What is the best way to select a single random record from a table and > > > falls within the "where" criteria i have defined? I don't want to return a > > > huge result set each time and then pick a random one > > > > Please define "random" in the context of your task. Do you want a > > different record every time? Or some non-deterministic record that could > > be the same every time is a possible solution? > > > > Oleg. > > It should be a different record each time. > I don't need a way to produce the same results again. > > ------------------------------------------------------------------------------ > Better than sec? Nothing is better than sec when it comes to > monitoring Big Data applications. Try Boundary one-second > resolution app monitoring today. Free. > http://p.sf.net/sfu/Boundary-dev2dev To give context to the issue, I am building my own icecast2 broadcaster. I want to have an Auto DJ feature which will pick a random song from the database which hasn't recently been played plus some other criteria. It really doesn't matter which record i get back from the database, I just need one at random. |
From: Adam B. <ada...@gm...> - 2012-04-18 17:25:22
|
Oleg Broytman <phd <at> phdru.name> writes: > > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg <adamberg <at> gmail.com> wrote: > > What is the best way to select a single random record from a table and > > falls within the "where" criteria i have defined? I don't want to return a > > huge result set each time and then pick a random one > > Please define "random" in the context of your task. Do you want a > different record every time? Or some non-deterministic record that could > be the same every time is a possible solution? > > Oleg. It should be a different record each time. I don't need a way to produce the same results again. |
From: Hans G. S. <geo...@sc...> - 2012-04-18 17:20:54
|
On Wed, Apr 18, 2012 at 08:38:42PM +0400, Oleg Broytman wrote: > On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg <ada...@gm...> wrote: > > What is the best way to select a single random record from a table and > > falls within the "where" criteria i have defined? I don't want to return a > > huge result set each time and then pick a random one > > Please define "random" in the context of your task. Do you want a > different record every time? Or some non-deterministic record that could > be the same every time is a possible solution? Obviously, i cannot defined «random» in his context, but I have a somewhat related problem. To me «random» means that every record is equally likely as the return of the next execution of the query, where «likely» can be entirely subjective seen from the user's point of view. In my context the issue is a queue of number crunching jobs, where a number of clients (10-100; maybe more) will query for the next parameter set to run the calculation for. A client receiving a job will set a field to indicate that it is taken, and transaction locking is used to avoid multiple clients snitching the same job at the same time. Ideally, I would have liked a query to retrieve the first unlocked record (it is useful but not necessary to order them by timestamp). Random selection, which makes it unlikely that a client will have to wait for the lock would be a useful second best. Or maybe there is another ingenious approach which I have not thought of. Admittedly, this is a quick and dirty solution which seems to work. -- :-- Hans Georg |
From: Oleg B. <ph...@ph...> - 2012-04-18 16:38:50
|
On Wed, Apr 18, 2012 at 12:30:10PM -0400, Adam Berg <ada...@gm...> wrote: > What is the best way to select a single random record from a table and > falls within the "where" criteria i have defined? I don't want to return a > huge result set each time and then pick a random one Please define "random" in the context of your task. Do you want a different record every time? Or some non-deterministic record that could be the same every time is a possible solution? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Adam B. <ada...@gm...> - 2012-04-18 16:30:21
|
What is the best way to select a single random record from a table and falls within the "where" criteria i have defined? I don't want to return a huge result set each time and then pick a random one, as the database is located outside of my network and accessed over the internet. -- Adam Berg |
From: Glenn R. <gru...@ed...> - 2012-04-13 17:20:12
|
Everything was running fine last night. Came in this morning and my test system is acting weird. I'm doing my best to find the answer but in the meantime, if someone knows what this is, I could use a bit of help. Thanks, Glenn Today: >>> from sqlobject import * Traceback (most recent call last): File "<stdin>", line 1, in <module> File "sqlobject.py", line 8, in <module> conn = connectionForURI(connection_string) NameError: name 'connectionForURI' is not defined System Setup: Python 2.7.2 on Windows XP Path = c:\python27;c:\python27\Scripts;C:\Python27\Lib\site-packages Installed pymssql Installed SQLObject 1.3.0 >easy_install -U SQLObject Searching for SQLObject Reading http://pypi.python.org/simple/SQLObject/ Reading http://sqlobject.org Reading http://sqlobject.org/ Reading http://sqlobject.org/devel/ Best match: SQLObject 1.3.0 Downloading http://pypi.python.org/packages/2.7/S/SQLObject/SQLObject-1.3.0-py2.7.egg#md5=42e649b0c1 08b75a1bec8f22e84270fa Processing SQLObject-1.3.0-py2.7.egg creating c:\python27\lib\site-packages\SQLObject-1.3.0-py2.7.egg Extracting SQLObject-1.3.0-py2.7.egg to c:\python27\lib\site-packages Adding SQLObject 1.3.0 to easy-install.pth file Installing sqlobject-admin script to c:\python27\Scripts Installing sqlobject-convertOldURI script to c:\python27\Scripts Installed c:\python27\lib\site-packages\sqlobject-1.3.0-py2.7.egg Processing dependencies for SQLObject Finished processing dependencies for SQLObject |
From: Glenn R. <gru...@ed...> - 2012-04-13 16:35:46
|
Nevermind. I would share with you the reason, but I don't want to get banned from The Internet. And yes. I mean 'The Whole Internet'. -Glenn |
From: Oleg B. <ph...@ph...> - 2012-03-31 11:49:50
|
On Sat, Mar 31, 2012 at 03:42:38PM +0400, Oleg Broytman wrote: > I'm pleased to announce version 1.3.0, the first stable release of branch > 1.3 of SQLObject. With this release I stopped supporting branch 1.1. > * Major update of FirebirdConnection: introspection was completely > rewritten and extended; ``charset`` was renamed to ``dbEncoding``; > a longstanding bug was fixed - pass port to connect(). Many kudos to Petr Jakes! Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |