Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old November 22nd, 2003, 06:56 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
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
File Type: gz db.tar.gz (1.4 KB, 219 views)

Last edited by telex4 : November 22nd, 2003 at 06:59 AM.

Reply With Quote
  #2  
Old November 26th, 2003, 02:13 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
You might find the PDO project interesting Telex:

http://sourceforge.net/docman/displ...&group_id=86244

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


Reply With Quote
  #3  
Old November 26th, 2003, 05:29 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
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.

Reply With Quote
  #4  
Old November 26th, 2003, 08:24 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #5  
Old November 26th, 2003, 09:22 AM
telex4's Avatar
telex4 telex4 is offline
Wacky hack
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 512 telex4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 25 m 29 sec
Reputation Power: 8
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.

Reply With Quote
  #6  
Old November 26th, 2003, 03:34 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #7  
Old November 29th, 2003, 12:34 AM
Strike Strike is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 383 Strike User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 27 sec
Reputation Power: 7
Send a message via ICQ to Strike Send a message via AIM to Strike Send a message via Yahoo to Strike
Parnassus is old and crappy. PyPi <http://www.python.org/pypi> is a much better alternative.

Reply With Quote
  #8  
Old November 29th, 2003, 06:26 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Yeah id agree with you strike but there are still allot of modules missing from PyPi (which is allot smaller than Parnassus)

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > New database interface


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway