473,750 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Seeking Python->mySQL OR module

aum
Hi,

I'm looking for an object-relational layer, which can wrap a MySQL
database into highly pythonic objects.

There seem to be dozens of packages which provide some of this
functionality, but all the ones I've looked at so far have major drawbacks.

What I'm looking for in an object-relational wrapper layer is:

1) Pure python
2) Talks to standard MySQLdb python module
3) No need for third-party modules (apart from standard python modules)
3) Can access *existing* tables on *existing* databases, without me
needing to
create python classes which define the columns
4) Can query existing databases to get table names, and open those tables
5) On opening the tables, can get a list of column names
6) Makes tables available as python objects
7) Elegant pythonic interface to these objects
8) No requirement to use SQL statements, but the ability to do so if
desired

Any suggestions?

Thanks in advance
a
Jul 18 '05 #1
2 1903
aum wrote:
Hi,

I'm looking for an object-relational layer, which can wrap a MySQL
database into highly pythonic objects.

There seem to be dozens of packages which provide some of this
functionality, but all the ones I've looked at so far have major
drawbacks.
I'm going to assume you haven't looked at my PyTable RDBMS Wrapper. I
know it's shamelessly self-promoting, but hey, what's life with shame,
really. Point-by-point below...
What I'm looking for in an object-relational wrapper layer is:

1) Pure python
Check.
2) Talks to standard MySQLdb python module
Check. Also PostgreSQL, which is where my day-to-day work is done.
3) No need for third-party modules (apart from standard python modules)
Not a check, but the only other package required is my BasicProperty
pure-python package, so IMO not a huge problem.
3) Can access *existing* tables on *existing* databases, without me
needing to
create python classes which define the columns
Check.
4) Can query existing databases to get table names, and open those tables
Check. Normally you don't "open" tables, you open connections to the
database(s) and then query the connection to the database for the tables
(and their contents).
5) On opening the tables, can get a list of column names
Check, though this support is more mature on PostgreSQL, and honestly I
don't use it myself. On MySQL the query is pretty darn trivial... more
work for me on PostgreSQL, but really, not a huge deal there once you
learn about psql's "echo" flag.
6) Makes tables available as python objects
Yes, tables are described as Schema objects. Rows are DBRow objects.
7) Elegant pythonic interface to these objects
Check IMO. Objects support regular x.y access for field values, fields
can be told to use particular classes for wrapping values via the table
schema, DBRows have methods for doing insert/update/refresh/delete
queries that use the tracked changes to the object to determine what to
actually send to the database.

The system does not, however, do automatic reference lookup or the like
(it lets you include the information in the schema you provide to let
you code such things, however). i.e. object.location _id doesn't
automagically get resolved via a background query to a location object,
you have to do that query yourself. Of course, if you need that, it's
pretty trivial to add the functionality, just override the property for
that field.

As with all things, there are some general principles by which one can
judge beauty in interface but the differences between any two
individuals response to the stimuli will outweigh the commonalities that
can be found. There is no artifice which can serve all purposes.
8) No requirement to use SQL statements, but the ability to do so if
desired
No check. SQL statements are required to get rows from the tables. i.e.

schema = findTable( 'person' )
item = schema.itemClas s( login = 'test', password='this' )
item.insertQuer y( APPLICATION.get DBConnection())
item.fname = 'Bill'
item.updateQuer y( APPLICATION.get DBConnection())
item.refreshQue ry( APPLICATION.get DBConnection())
item.deleteQuer y( APPLICATION.get DBConnection())

can all be done without SQL, but to access rows of the table you need to
do something akin to:

for person in schema.query( """SELECT * FROM person WHERE fname LIKE
'M%';""" ):
print person.login, person.fname, person.lname

There may be some better way to determining what rows to load from an
SQL database, but I find the SQL queries work pretty well at this level
of interface. Anything higher-level and you start needing to restrict
the user markedly.
Any suggestions?


Give in to the idea that there is no perfect object-relational mapper :)
.. There is a high impedance mismatch between the two domains, so that
as you make any given aspect of an interface more natural you tend to
make other aspects less natural and/or more difficult to work around.
Decide which aspects are most important and go with whichever mapper
works most closely to that which accomplishes your ends (which appears
to be what you're doing).

Your particular requirements seem fairly close, IMO, to my own, so seems
like PyTable might be for you, but then I have an obvious interest in
conquering this cold cruel world (I'm in Canada :) ) and bringing to it
the light of my relational database wrapper ;) .

http://pytable.sourceforge.net/

Good luck in your search,
Mike

_______________ _______________ _________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #2
aum
On Mon, 02 Feb 2004 22:15:52 -0500, Mike C. Fletcher <mc******@roger s.com>
wrote:
Give in to the idea that there is no perfect object-relational mapper :)
After several hours of looking, this is dawning on me.
. There is a high impedance mismatch between the two domains
I'm really seeing what you mean. And how!

Back in my bad old PHP days, the paradigm difference wasn't as severe.
But since I've disinfected myself of PHP and settled into Python, the
two worlds are universes apart.

The general feeling I get is that DB-wrapping is probably a personal
thing, extremely subject to the needs and tastes of the programmer.

In my case, I think I'll go down the track of having a single module for
all
things SQL, and writing specific funcs/classes for specific queries.
http://pytable.sourceforge.net/
Thx for the recommendation. I've downloaded it, and am studying it along
with a few others.

Good luck in your search,
Mike

_______________ _______________ _________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2062
by: Matt Shomphe | last post by:
Are there any guidelines for packaging a pure python module? Specifically, say I have a set of 10 functions, all of varying behaviors (no unifying theme to bind them together into clear subsets), that I would like to make available to others. What is the best structure for the distributed module? A single file called "functions.py" that people can put in "site-packages"? A subdirectory called "MyFunctions" with an "__init__.py" and the...
5
4775
by: Bart Simpson | last post by:
Hi, I want to control 'Scheduled Tasks' in Windows 2003 by python program. But I couldn't find any Python module about win32 'Scheduled Tasks'. I could find only Perl module about it. (see http://taskscheduler.sourceforge.net) But, I want to control 'Scheduled Tasks' by python :) Is there any python module about win32 'Scheduled Tasks'?
1
5469
by: sam | last post by:
Hi, Had anyone written any python module for webmin? Since webmin is written in perl, but I want to write a python app/module used by webmin. If you know the detail of writing a python module for use in perl webmin, please drop me some guideline. Perhaps It is better off to find/write a python version of webmin first. Thanks
1
1592
by: David | last post by:
I have this error message poping up when I try to import a module I made in C using the Python/C API. Everything compiles like a charm. Gives me this error message : Traceback (most recent call last): File "mod_test.py", line 4, in ? import utm ImportError: dynamic module does not define init function (initutm)
1
2572
by: wen | last post by:
i have written python extend module by c/c++, but i saw a module of a software(pyMOL, you can get it from http://pymol.sourceforge.net/) called _cmd.pyd instead of _cmd.dll. and it is written by c/c++ also, the author use makefile to compile it into _cmd.pyd. i have some question about it: 1. what's the difference between them? i saw the code is same as common c++ extended python module, can i use microsoft visual C++ to create a dll...
0
1250
by: RJS | last post by:
I've begun a Python module to provide a complete interface to the Meade LX200 command set: http://rjs.org/Python/LX200.py and would like input from potential users or people interested in developing it further. The code I have online is a very alpha start - it contains all of the command set, parsed from http://www.meade.com/support/LX200CommandSet.pdf reg-exp'd into methods, but few methods are actually complete yet. My thinking is to...
1
4860
by: RayS | last post by:
I've begun a Python module to provide a complete interface to the Meade LX200 command set: http://rjs.org/Python/LX200.py and would like input from potential users or people interested in developing it further. The code I have online is a very alpha start - it contains all of the command set, parsed from http://www.meade.com/support/LX200CommandSet.pdf reg-exp'd into methods, but few methods are actually complete yet. My thinking is to...
4
2451
by: Con | last post by:
Hi, how does properly install the Python MySQL db module for Mac OS X? I was only able to locate the Win32 modules. Thanks in advance, -Conrad
0
1111
by: Gabriel Genellina | last post by:
En Thu, 10 Jul 2008 14:02:29 -0300, Bhagwat Kolde <bbkolde@gmail.com> escribi�: If it is a single Python module, you can put it anywhere in the Python path. A good place may be the site-packages subdirectory. Execute this line to see the list of directories that are currently searched for modules: python -c "import sys; print '\n'.join(sys.path)"
1
1016
by: Carl | last post by:
Does anyone know of a package that can connect and query a mysql server that is platform independent and does not need to compile any extra c modules (IE a pure python module)?
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9394
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.