#1
  1. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14

    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'}
    Attached Files
    Last edited by telex4; November 22nd, 2003 at 06:59 AM.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    You might find the PDO project interesting Telex:

    http://sourceforge.net/docman/displa...group_id=86244

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    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.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
    programming language development: www.netytan.com Hula

  8. #5
  9. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    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.
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
    programming language development: www.netytan.com Hula

  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Parnassus is old and crappy. PyPi <http://www.python.org/pypi> is a much better alternative.
  14. #8
  15. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Yeah id agree with you strike but there are still allot of modules missing from PyPi (which is allot smaller than Parnassus)

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo