473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Pythonic wrappers for SQL?

I need to do some data manipulation, and SQLite is a nice little
product for it, except of course that I'd need to write SQL. Are
there any good libraries out there that let one write (basic) queries
in a Pythonic syntax, rather than directly in SQL?

Thanks,
Ken
Jan 14 '06 #1
4 1529
Il 2006-01-14, Kenneth McDonald <ke****************@sbcglobal.net> ha scritto:
I need to do some data manipulation, and SQLite is a nice little
product for it, except of course that I'd need to write SQL. Are
there any good libraries out there that let one write (basic) queries
in a Pythonic syntax, rather than directly in SQL?


You need an ORM

Try SQLAlchemy - http://sqlalchemy.org

Have fun
--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
Jan 14 '06 #2
Kenneth McDonald si è profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni:
there any good libraries out there that let one write (basic) queries
in a Pythonic syntax, rather than directly in SQL?


You need an ORM. Beyond SQLAlchemy (I don't have experience with it) i
would suggest you try out SQLObject and PyDO.

Just a clue: although they prevent you from writing SQL, you'll have to
learn SQL basics anyway, or you won't understand the docs.

If you simply want to forget SQL, you can try out Axiom:

http://divmod.org/trac/wiki/DivmodAxiom

It's a native object database; it uses sqlite as backend, but that's
totally transparent to the user, you'll never be asked to enter a single
sql statement.

--
EleSSaR^ <el*********@despammed.com>
--
Togli .xyz dalla mia email per contattarmi.
Jan 14 '06 #3
Just to chime in with Steve Holden on taking the why-not-learn-SQL
route. Chris Fehily's new book, SQL, A Visual QuickStart Guide (2nd Ed)
is a masterpiece and goes well on the bookshelf with his equally lucid
Python QuickStart Guide.

Cheap, too, for what you get.

http://www.amazon.com/exec/obidos/as...icharddooling/

rpd

Jan 15 '06 #4
On 1/14/06, EleSSaR^ <el*********@despammed.com> wrote:
Kenneth McDonald si è profuso/a a scrivere su comp.lang.python tutte queste
elucubrazioni:
there any good libraries out there that let one write (basic) queries
in a Pythonic syntax, rather than directly in SQL?


You need an ORM. Beyond SQLAlchemy (I don't have experience with it) i
would suggest you try out SQLObject and PyDO.

Just a clue: although they prevent you from writing SQL, you'll have to
learn SQL basics anyway, or you won't understand the docs.

If you simply want to forget SQL, you can try out Axiom:


Or - as a word play in this case - try my module ForgetSQL [1]

(Also available in a new and backwards-incompatible beta version [2]
which should be easier to get started with, has more extensive unit
tests, but has only been tested with MySQL and SQLite)

[1] http://soiland.no/software/forgetsql/
[2] http://soiland.no/i/src/forgetsql2/

Example code from [2]

import MySQLdb, forgetsql2
# Connect to MySQLdb using keyword parameters
db = forgetsql2.generate(MySQLdb, {db='fish'})

# Iterate through generated class from the table "postal"
for postal in db.Postal:
# Print normal fields
print postal.postal_no, postal.postal_name, postal.municipal_id
# Follow the foreign key municipal_id to retrieve the entry
# from the Municipal class
municipal = postal.get_municipal()
print municipal.municipal_name

# Retrieve by primary key
rogaland = db.County(county_id=11)
# Iterate over municipals that have foreign keys to rogaland
for municipal in rogaland.get_municipals():
print municipal.municipal_name

# Load by primary key, change, and save
postal = db.Postal(postal_id=4042)
postal.postal_name = "Fish land"
postal.save()
--
Stian Søiland In theory there is no difference between theory
Birmingham, UK and practice. In practice there is. [Berra]
http://soiland.no/
=/\=
Jan 16 '06 #5

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

Similar topics

9
by: Tom Evans | last post by:
My basic question: If I have a specific interface which I know is going to be implemented by a number of classes, but there is no implementation commonality between them, what is the preferred...
3
by: Paul Rudin | last post by:
I'm having a problem with the python wrappers generated from a type library. The symptom is that I get failures to find connections points inside the wrappers when called from DispatchWithEvents...
18
by: Adrian B. | last post by:
Does anyone know of a framework or library that will enable me to use publish/subscribe comms? I want to create a server (using Python) running on a Unix box that will accept client connections...
1
by: asdf sdf | last post by:
i need some advice. i'm a back end programmer historically, but have been exploring python for webapps and enjoying it. i need to build some simple Win client-server or standalone apps. the...
11
by: Charles Krug | last post by:
I've a function that needs to maintain an ordered sequence between calls. In C or C++, I'd declare the pointer (or collection object) static at the function scope. What's the Pythonic way to...
4
by: Carl J. Van Arsdall | last post by:
It seems the more I come to learn about Python as a langauge and the way its used I've come across several discussions where people discuss how to do things using an OO model and then how to design...
3
by: jnair | last post by:
My Tead Lead my object counter code seen below is not pythonic class E(object): _count = 0 def __init__(self): E._count += 1 count = property(lambda self: E._count ) def test(): if...
1
by: TC | last post by:
Every time I open my project, I get a warning which says "There are updated custom wrappers available for the following referenced components: Office." When I double-click on the warning, I get...
26
by: Frank Samuelson | last post by:
I love Python, and it is one of my 2 favorite languages. I would suggest that Python steal some aspects of the S language. ------------------------------------------------------- 1. Currently...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.