Python Development with Databases?

Status
Not open for further replies.

Maverick

Active Member
179
2011
9
0
Hey all, so I like to start all my technical questions by letting people know I'm a crap-flinging monkey when it comes to programming/scripting.

I do have a book on python I'm working on/going to be working on to help me get solid with all this (followed by a book on C, perhaps, which I already have but have decided python would be better for me to start with mostly because at the moment I'm doing a lot of learning-by-doing and that doing is kinda pushed by my wanting to make scripts to do stuff I couldn't possible start working on with C at this moment.

That said, one of the things I've begun to start wanting to work databases a little and I've had no experience with them outside of some time back when I was doing things with vBulletin software.

The ORM vs. DRM discussion confuses me pretty quickly, but from what I know at this point, seems like long term I'm going to want to be using SQL databases, and of all the ones out there I (at the moment, anyways) am leaning towards PostgreSQL (mostly because of its roots, functionally I'm just not smart enough to be able to judge differences and don't see a reason to believe it'll matter much).

I suppose now I get to my actual question which is: what is involved in posting some basic information to a PostegreSQL database with Python?

There seems to be a lot of "Drivers" or "Wrappers" for the "Python DB API 2.0". Does this mean I can't just use python functionality to post to the database? Are there any good tutorials/examples of all this?

How involvement is the creation of the databases?

At the moment I suppose I'd be wanting to have a fair number of fields-per-entry; but it seems like there is a lot of SQL programming/language/whatever involved that I might not be understanding?

Thank for any help you can give!
 
2 comments
What's your question exactly? From your post I'm not quite sure if your looking for help with *SQL, Python or interacting with *SQL from Python. Little bit more specific, please ;).
 
Here's how to proceed. The Python DB API (PEP 249) provides a skeleton for all the db drivers to bind with the language. Its like unifying the syntax for common operations (the Python part of it). So you connect to the database, execute SQL, fetch data and stuff with pretty much the same python statement (the SQL syntax varies depending upon the 'flavour' used).

So, besides Python, you should be aware of some SQL to make it work. Ultimately its your queries that turn out to be the logic. The wrappers are only providing the outline to make connections and stuff easier.

However, if you find the SQL task a bit daunting, ORMs are there to encapsulate stuff. But, its always better to know some SQL before taking the plunge to an ORM (one gets lazy after the switch :P )

Hope that explains it all.

Regards,
Gaurav
 
Status
Not open for further replies.
Back
Top