The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
New database interface
Discuss New database interface in the Python Programming forum on Dev Shed. New database interface Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 22nd, 2003, 06:56 AM
|
 |
Wacky hack
|
|
Join Date: Apr 2001
Location: London, England
Posts: 513
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
|
|
|
New database interface
As part of my project to make a decent framework to develop web sites with that isn't as "heavy" as Zope, I've started work on a module to make handling databases nice and easy.
There are two things that annoy me about databases:
1) When you use a new host and find that you have to change all of your MySQL code to, for example, flat-file database code
2) Having to write the same lines over and over for queries, etc.
So this module tries to make the kinds of simple operations I need for web sites nice and easy. I've attached the module so far to this message along with the requisite config.py.
But here's an example of its use:
Code:
>>> import db
>>> mydb = db.DB('mysql')
>>> mydb.info()
{'tables': ['calendar', 'campaigns', 'pages', 'pressreleases', 'rdb_articles', 'rdb_categories', 'resources'],
'hostname': 'localhost', 'dbname': 'readingc_campaignforum', 'ctime': 'Sat, 22 Nov 2003 12:46:46 +0000'}
>>> mydb.fetchRow('calendar', 'name,eventdate', 'id', '6')
{'name': 'Human Rights in Chechnya', 'eventdate': '2003-03-10'}
Last edited by telex4 : November 22nd, 2003 at 06:59 AM.
|

November 26th, 2003, 02:13 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
__________________
programming language development: www.netytan.com – Hula
|

November 26th, 2003, 05:29 AM
|
 |
Wacky hack
|
|
Join Date: Apr 2001
Location: London, England
Posts: 513
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
|
|
Ah, magic; had I found that first, I might have used it instead of making my own. Then again, it's always fun and educational trying to roll your own solution
It's quite frustrating coming from Perl to Python in this respect; I find Python much nicer to code with, but the standard library is missing some really useful and time saving features found in Perl's CPAN.
|

November 26th, 2003, 08:24 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Yeah i gotta agree with you there, def loadsa fun! The thing you have to remember though is that where the vaults of parnassus are pretty small.. CPAN is backed by Sun  .. and with that much comercial input what can you expect!
http://www.vex.net/parnassus/
Give it a little time and see what happens  .. Pythons becoming more popular every day.. but if parnassus hasn't grown considerably within the next 5 years where gonna have to make our own CPAN style resource for Python!
Mark.
|

November 26th, 2003, 09:22 AM
|
 |
Wacky hack
|
|
Join Date: Apr 2001
Location: London, England
Posts: 513
Time spent in forums: 1 h 38 m 37 sec
Reputation Power: 13
|
|
|
Yers, I think Parnassus and Python are just young, or rather they haven't been in the limelight and haven't had as many "3rd party" developers making good modules for it for as long.
The PDO project does look very promising, though in a way it'd be nice if they made it as similar as possible to the Perl DBI system, which is also AFAIK similar to something in C.
|

November 26th, 2003, 03:34 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
def, just wait till Python hits the big screen, and i know it will eventually
Yeah, would be nice if we could keep the DBI the same (or as close as poss) for all/most langs, this way if you know DBI in one you know it in the other
Mark.
|

November 29th, 2003, 12:34 AM
|
|
Contributing User
|
|
Join Date: Dec 2001
Location: Houston, TX
Posts: 383
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 12
|
|
|

November 29th, 2003, 06:26 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Yeah id agree with you strike but there are still allot of modules missing from PyPi (which is allot smaller than Parnassus)
Mark.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|