mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-05 23:20:19 +00:00
1 line
12 KiB
JSON
1 line
12 KiB
JSON
[{"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301196603.1452069, "message": ":-)", "group_id": 81, "id": 449230}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301187814.658345, "message": "I am new to web development/programming/computering and have been using django however I seem to keep stumbling when trying to work with the ORM. It seems much of my problem is a lack of understanding concerning SQL, does anyone know of a good SQL tutorial that could give me some background to be better able to make use of django and the ORM, thanks.", "group_id": 81, "id": 448863}, {"user_id": 25106, "stars": [], "topic_id": 15547, "date_created": 1301188318.5231421, "message": "Really, the best way to learn SQL is just to use it. Open up the manual for your database of choice in a web browser, run an SQL command line in a terminal, and start creating tables and running queries. A lot of the magic of SQL is in queries and joins, so practice creating schemas and trying to get answers to various questions by writing good SELECT and JOIN statements.", "group_id": 81, "id": 448880}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301188678.264833, "message": "word, will do that then, thanks", "group_id": 81, "id": 448906}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301191085.3455961, "message": "Also it is worth mentioning that the Django ORM doesn't really expose the full power of SQL, so be careful getting too much of a taste of the Real Thing :-)", "group_id": 81, "id": 448990}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301194779.597403, "message": "i was using them but they gave only counts and didnt return the actual objects i wanted", "group_id": 81, "id": 449118}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301193479.2493911, "message": "really? I have alot to learn about sql", "group_id": 81, "id": 449075}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301193334.437793, "message": "i can always use the real deal sql if i need though correct? I don't have to be constrained by the ORM do I?", "group_id": 81, "id": 449071}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301193382.8508379, "message": "@thesteve Technically yes, but even making your models using Django presents a substantially limited (but still quite useful) subset of normal SQL power.", "group_id": 81, "id": 449074}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194580.330267, "message": "The advantage of the Django approach is that you don't need to know (as much) SQL to use the model system as compared to something like SQLAlchemy, which is really pretty literal SQL-as-Python.", "group_id": 81, "id": 449110}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194949.1744311, "message": "But you just said you want the actual items, not just a count", "group_id": 81, "id": 449124}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195313.839829, "message": "so if i want the actual models i need to build my dict manually by adding the fields i want", "group_id": 81, "id": 449161}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301193821.163244, "message": "ORMs exist on a spectrum between object-ish and relation-ish. Django's is closer to the object model, so it forgoes exposing some of the relational logic (though they keep working on improving that).", "group_id": 81, "id": 449082}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194501.4170661, "message": "NoSQL is an every wider range of styles, there is really no rhyme of reason to things labelled \"NoSQL\"", "group_id": 81, "id": 449108}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301193982.8542349, "message": "I have been trying to implement what I thought would be some fairly simple count functionality similar to the example here http://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra-manager-methods with the custom poll_counts methods and have been very confused", "group_id": 81, "id": 449086}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301194986.691119, "message": "I want both", "group_id": 81, "id": 449128}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195656.4343579, "message": "Putting the logic in Python instead of SQL is definitely fine when getting started", "group_id": 81, "id": 449194}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301196241.8204291, "message": "Heh, the fun part is when you realize that some logic must be done in SQL to avoid cross-tab race conditions.", "group_id": 81, "id": 449216}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301194117.7560589, "message": "as far as object-ish and relation-ish, do nosql options also run that spectrum?", "group_id": 81, "id": 449093}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301194630.4365001, "message": "but if you need to use raw sql to get something as simple as counts as in the example seems like that advantage falls away quickly", "group_id": 81, "id": 449113}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194746.1458459, "message": "@thesteve You don't, in this case you would use an annotated queryset http://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate", "group_id": 81, "id": 449117}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194834.2844751, "message": "If you want the objects, just query them and use len(). The point of using an aggregate is to not have to transfer the object rows.", "group_id": 81, "id": 449121}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301194911.0450089, "message": "I have two tables Items and Votes, I am trying to count all of the instances in votes for each item", "group_id": 81, "id": 449123}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301194998.820251, "message": "Then just query the items and get the count of them in Python", "group_id": 81, "id": 449130}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195054.01296, "message": "and then create new dict with a count field to return to the template?", "group_id": 81, "id": 449132}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195081.418344, "message": "I was trying to do that but was getting errors when trying to add the objects to a new dict", "group_id": 81, "id": 449134}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195136.2226501, "message": "d = {}; for item in qs: d.setdefault(item.vote_id, []).append(item)", "group_id": 81, "id": 449138}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195139.105289, "message": "or something like that", "group_id": 81, "id": 449139}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195265.957844, "message": "Like I said, the advantage of using the aggregate is only to save time when you _don't_ want the actual models", "group_id": 81, "id": 449157}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195094.103235, "message": "Yep, loop over the items returned and keep the running totals", "group_id": 81, "id": 449135}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195348.036607, "message": "aggregate will give me info about the queryset only", "group_id": 81, "id": 449164}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195356.8855021, "message": "Not 100% sure what you are asking, but you don't want to use aggregates here", "group_id": 81, "id": 449165}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195505.936115, "message": "There are ways of improving performance using more specialized ORM tricks, but for a simple impl that should be fine", "group_id": 81, "id": 449183}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195555.6538689, "message": "im sure eventually much of what i have will change", "group_id": 81, "id": 449188}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195381.3553641, "message": "makes two of us", "group_id": 81, "id": 449167}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195405.3951941, "message": "i am trying to build the dict now using your suggested approach", "group_id": 81, "id": 449170}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195465.844166, "message": "The qs in this case would probably just be Items.objects.all()", "group_id": 81, "id": 449180}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195544.7640541, "message": "yeah, i am not worrying too much about performance now and am just trying to get the funtionality i want", "group_id": 81, "id": 449187}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195967.432092, "message": "I tend to avoid it since it is easier to scale web servers than DB servers", "group_id": 81, "id": 449207}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195993.0551331, "message": "Finding the right balance is part of the fun of each application :)", "group_id": 81, "id": 449208}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195510.523576, "message": "well i am breaking them out by different Contests and current votes but i seem to have that much correct", "group_id": 81, "id": 449184}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301195858.9045751, "message": "ideally should calculations and number crunching type operations be done in the database?", "group_id": 81, "id": 449202}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301195953.175822, "message": "There are many disagreements on that", "group_id": 81, "id": 449206}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301196020.8634629, "message": "can't wait for the fun to start and headaches to stop", "group_id": 81, "id": 449209}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301196403.40082, "message": "man, let me figure out how to build a dict in python before i have to start figuring out race conditions", "group_id": 81, "id": 449224}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301197384.6223249, "message": "your suggesting to build the dict is working but not returning a count, should i be initialising a count field and then using if item in d: add 1 to the count, else use the setdefault syntax?", "group_id": 81, "id": 449272}, {"user_id": 1736, "stars": [], "topic_id": 15547, "date_created": 1301198781.1301301, "message": "After you have them sorted the way you want, just use len() on each list (or the length filter if in a template)", "group_id": 81, "id": 449313}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301205148.2150221, "message": "you sir are a gentleman and a scholar, thank you kindly", "group_id": 81, "id": 449668}, {"user_id": 13496, "stars": [], "topic_id": 15547, "date_created": 1301213018.1495781, "message": "I have the opposite problem - after a few years of using Django, I'm forgetting how to write SQL queries. If you don't already know SQL, there's no reason you *shouldn't* learn it, but if you just want to be productive with Django, I'd say focus on learning the ORM and don't worry about SQL for now.", "group_id": 81, "id": 450045}, {"user_id": 12927, "stars": [], "topic_id": 15547, "date_created": 1301234394.0005131, "message": "im not married to django or its orm, just trying to implement my ideas the fastest way possible, mvp and all", "group_id": 81, "id": 451127}, {"user_id": 22200, "stars": [], "topic_id": 15547, "date_created": 1301380835.170923, "message": "@thesteve don't worry about the headaches, it comes with SQL. it's not as if Django is like our favorite Python-based game ;) http://bit.ly/fD8Ny", "group_id": 81, "id": 466989}] |