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 2 1854
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.itemClass( login = 'test', password='this' )
item.insertQuery( APPLICATION.getDBConnection())
item.fname = 'Bill'
item.updateQuery( APPLICATION.getDBConnection())
item.refreshQuery( APPLICATION.getDBConnection())
item.deleteQuery( APPLICATION.getDBConnection())
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/
On Mon, 02 Feb 2004 22:15:52 -0500, Mike C. Fletcher <mc******@rogers.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/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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),...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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)?
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |