From mark.smith at practicalpoetry.co.uk Mon Jan 23 10:50:41 2012 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Mon, 23 Jan 2012 09:50:41 +0000 Subject: [Python Edinburgh] Pub Meetup on Tuesday! Message-ID: Hello All, There's a pub meetup tomorrow night at Berts Bar at 18:30pm for (vaguely) Python chat and beer (and pie for those who are hungry!) I'll have a Python logo printout on the table for anyone new - if there's anyone on the list who hasn't yet made it along, please do - we're a friendly bunch! As agreed towards the end of last year, we're going to be putting more emphasis on content for the monthly meetup. I'm hoping to get this kicked off for February, so next month will see a change of venue, possibly a different day of week, and a talk by Mathew on using Chef. Given that Chef is actually a Ruby technology (although very useful for the Pythonista) I may cross-post to the Ruby group once I have the talk details arranged. See you tomorrow! --Mark From alex at alexbird.co.uk Wed Jan 25 00:19:06 2012 From: alex at alexbird.co.uk (Alex Bird) Date: Tue, 24 Jan 2012 23:19:06 +0000 Subject: [Python Edinburgh] using django to create db for app? Message-ID: Hey Pythonistas, Sorry not to make it yet another meetup! I'm just wondering if anyone else is using django to build the sqlite3 database for a smartphone app? I'm hoping to make it generate the basic model code too, maybe some queries, and ultimately snapshots and update diffs to allow the data in the app to be updated. Interested to know if this sounds like something that already exists?! Cheers, Alex -- Sent from my fur lined mountain lair -------------- next part -------------- An HTML attachment was scrubbed... URL: From cabalamat at gmail.com Wed Jan 25 00:43:40 2012 From: cabalamat at gmail.com (Philip Hunt) Date: Tue, 24 Jan 2012 23:43:40 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: References: Message-ID: On 24 January 2012 23:19, Alex Bird wrote: > Hey Pythonistas, > > Sorry not to make it yet another meetup! > > I'm just wondering if anyone else is using django to build the sqlite3 > database for a smartphone app? Do you mean a website designed to be accessed by smartphones, or do you mean an application that will run on a smartphone's internal web server? From dougal85 at gmail.com Wed Jan 25 09:24:59 2012 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 25 Jan 2012 08:24:59 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: References: Message-ID: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> On Tuesday, 24 January 2012 at 23:43, Philip Hunt wrote: > On 24 January 2012 23:19, Alex Bird wrote: > > Hey Pythonistas, > > > > Sorry not to make it yet another meetup! > > > > I'm just wondering if anyone else is using django to build the sqlite3 > > database for a smartphone app? > > > > Do you mean a website designed to be accessed by smartphones, or do > you mean an application that will run on a smartphone's internal web > server? I had guessed that Alex meant running the code on the phone, and perhaps only using Django for its ORM. If this is the case, the first hurdle will be running the code, i think with Jython you'll get something working on Android but it will probably be a massive paid. On iOS I guess your out of luck. Dougal From miles at assyrian.org.uk Wed Jan 25 14:31:24 2012 From: miles at assyrian.org.uk (Miles Gould) Date: Wed, 25 Jan 2012 13:31:24 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> Message-ID: <4F20042C.2060301@assyrian.org.uk> On 25/01/12 08:24, Dougal Matthews wrote: > I had guessed that Alex meant running the code on the phone, and perhaps > only using Django for its ORM. If this is the case, the first hurdle will be > running the code, i think with Jython you'll get something working on > Android but it will probably be a massive pain. Scripting Layer for Android might be useful: http://code.google.com/p/android-scripting/ I've yet to try it out, though. Miles From dougal85 at gmail.com Wed Jan 25 15:42:02 2012 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 25 Jan 2012 14:42:02 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: <4F20042C.2060301@assyrian.org.uk> References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> <4F20042C.2060301@assyrian.org.uk> Message-ID: <9A791135BB2D4CBF82B1B1C1D59B3D99@gmail.com> On Wednesday, 25 January 2012 at 13:31, Miles Gould wrote: > Scripting Layer for Android might be useful: > > http://code.google.com/p/android-scripting/ > > I've yet to try it out, though. It's neat, although you can't package apps up for the app store. Or, you couldn't when I looked at it about a year or so ago :) From alex at alexbird.co.uk Wed Jan 25 20:44:21 2012 From: alex at alexbird.co.uk (Alex Bird) Date: Wed, 25 Jan 2012 19:44:21 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> Message-ID: Oh, right, neither in fact! I was simply wanting to use django as the admin interface for creating a static (though I guess it needn't be) database which lives in the app. The file could be part of the app bundle and/or a download. Of course not all apps need to keep much data, or *can* because it needs to be updated, but for some this is a key part. There's no reason, in principle, why this database couldn't also back a webservice or website, but sqlite3 probably wouldn't be your first choice for that. Following on from django's DRY principles, I also want to generate the base model classes, in Objective-C in this case, from the model code. To keep things simple, these would be subclassed for use, so the base classes corresponding to a database file can be 'dropped into' the app at the same time; any breaking changes would need to be resolved manually. I'm definitely not wanting to run django on the phone, or any internal webserver, a-la-PhoneGap. Nor do I want to create any sort of ORM to run on the phone. I'm sure there are specific use cases for these approaches, but for performance and ease of debugging I don't think either is great. Cheers, Alex On 25 January 2012 08:24, Dougal Matthews wrote: > > > On Tuesday, 24 January 2012 at 23:43, Philip Hunt wrote: > > > On 24 January 2012 23:19, Alex Bird alex at alexbird.co.uk)> wrote: > > > Hey Pythonistas, > > > > > > Sorry not to make it yet another meetup! > > > > > > I'm just wondering if anyone else is using django to build the sqlite3 > > > database for a smartphone app? > > > > > > > > Do you mean a website designed to be accessed by smartphones, or do > > you mean an application that will run on a smartphone's internal web > > server? > > I had guessed that Alex meant running the code on the phone, and perhaps > only using Django for its ORM. If this is the case, the first hurdle will > be > running the code, i think with Jython you'll get something working on > Android but it will probably be a massive paid. On iOS I guess your out of > luck. > > Dougal > > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > -- Sent from my fur lined mountain lair -------------- next part -------------- An HTML attachment was scrubbed... URL: From cabalamat at gmail.com Thu Jan 26 03:57:52 2012 From: cabalamat at gmail.com (Philip Hunt) Date: Thu, 26 Jan 2012 02:57:52 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> Message-ID: On 25 January 2012 19:44, Alex Bird wrote: > Oh, right, neither in fact! > > I was simply wanting to use django as the admin interface for creating a > static (though I guess it needn't be) database which lives in the app. That's eminently doable: you use Django's ORM to define the database and then the admin interface to populate it. This then produces an sqlite file which (I presume but haven't checked) is portable between sqlite installations. >?The > file could be part of the app bundle and/or a download. ?Of course not all > apps need to keep much data, or can because it needs to be updated, but for > some this is a key part. ?There's no reason, in principle, why this database > couldn't also back a webservice or website, but sqlite3 probably wouldn't be > your first choice for that. If your database is small you may want to just use a flat ascii file, or python data statements like this: data = [ ["Fred Blogs", "123 Acacia Avenue", "EH12 1RS"], ...etc... ] which can then very easily be transformed into whatever data format you like. From alex at alexbird.co.uk Thu Jan 26 11:16:24 2012 From: alex at alexbird.co.uk (Alex Bird) Date: Thu, 26 Jan 2012 10:16:24 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> Message-ID: On 26 January 2012 02:57, Philip Hunt wrote: > > That's eminently doable: you use Django's ORM to define the database > and then the admin interface to populate it. > > This then produces an sqlite file which (I presume but haven't checked) is portable between sqlite installations. > It seems to work fine. As long as you have the same major version of sqlite, I suspect. At the moment the admin is just a nice bonus for checking the data. I may get around to splitting the database and adding some meta-admin for managing imports and snapshots. I also thought it could be nice for prototyping tricky queries. By default though, django doesn't really expose you to the SQL, because it's introspecting and building queries on the fly, and extracting it is discouraged for this reason. I don't think it will cause problems in this case, but that does make it harder to find information about doing it. > If your database is small you may want to just use a flat ascii file, > or python data statements like this: > > data = [ > ["Fred Blogs", "123 Acacia Avenue", "EH12 1RS"], > ...etc... ] > > which can then very easily be transformed into whatever data format you > like. > The data is quite big, and comes from a variety of sources. The other attraction of python though is that I spent years scraping data with python (helped build skyscanner's current system) so, while I'm quite rusty, this bit I'm happy with :o) The bit I'm least sure about is delving into django to examine the model and generate code from it. For example, I need to know the actual column name as well as the name in the model. But It's probably easier than I think...? Cheers, Alex -- Sent from my fur lined mountain lair -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Thu Jan 26 11:37:11 2012 From: dougal85 at gmail.com (Dougal Matthews) Date: Thu, 26 Jan 2012 10:37:11 +0000 Subject: [Python Edinburgh] using django to create db for app? In-Reply-To: References: <20479FC4DE3740678F3B6378F809D1CD@gmail.com> Message-ID: <84ED2C4331B34B03B56A0B5AF57EEBA2@gmail.com> > The bit I'm least sure about is delving into django to examine the model and generate code from it. For example, I need to know the actual column name as well as the name in the model. But It's probably easier than I think...? Depends how easy you think ;) but yeah, its pretty easy; http://dpaste.com/693486/ You'll notice the name and a bunch of 'Nones' in there. The column is almost always the name - but you can set a custom column name too with things like; name = CharField(max_length=30, db_column="users_name") Basically, dig around in Model._meta, you'll find everything you need in there. It's a private API, so technically could be changed in a new Django version, but its not likely as it would break loads of code that is in the wild (south for example).