473,385 Members | 1,676 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,385 software developers and data experts.

DB access without object-relation mapping?

kj

Python noob here.

I want to write a script that creates and populates a simple Postgres
database.

The word on the street is to use something like SQLAlchemy for
database access in Python, but my experience in the past with
packages that perform automated SQL generation has been awful, so
I always return to lighter-weight solutions that allow me to write
my own SQL. (E.g. when coding in Perl I've used Perl's DBI package
and drivers, rather than the likes of Class::DBI.) So what's the
standard Python way to send SQL directly to a Postgres database
and get back results?

TIA!

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jul 29 '08 #1
4 1050
On Jul 29, 11:20*am, kj <so...@987jk.com.invalidwrote:
Python noob here.

I want to write a script that creates and populates a simple Postgres
database.

The word on the street is to use something like SQLAlchemy for
database access in Python, but my experience in the past with
packages that perform automated SQL generation has been awful, so
I always return to lighter-weight solutions that allow me to write
my own SQL. *(E.g. when coding in Perl I've used Perl's DBI package
and drivers, rather than the likes of Class::DBI.) *So what's the
standard Python way to send SQL directly to a Postgres database
and get back results?

TIA!

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Hi,

I believe there are a couple of options but pyscopg, and PyGreSQL seem
to be popular.

Tim
Jul 29 '08 #2
On 29 Jul, 17:20, kj <so...@987jk.com.invalidwrote:
>
*So what's the
standard Python way to send SQL directly to a Postgres database
and get back results?
Take a look at this page:

http://wiki.python.org/moin/DatabaseInterfaces

I've used psycopg2 and pyPgSQL successfully, although pg_proboscis
looks very interesting, too.

Paul
Jul 29 '08 #3
kj
In <cb**********************************@56g2000hsm.g ooglegroups.comTim Henderson <ti******@gmail.comwrites:
>I believe there are a couple of options but pyscopg, and PyGreSQL seem
to be popular.
Great. Thanks!

kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jul 29 '08 #4
kj <so***@987jk.com.invalidwrites:
The word on the street is to use something like SQLAlchemy for
database access in Python, but my experience in the past with
packages that perform automated SQL generation has been awful, so I
always return to lighter-weight solutions that allow me to write my
own SQL.
Using SQLAlchemy, you *can* write your own SQL (with its 'text' query
type to feed explicit SQL text on the connection); you just don't
*need* to for the majority of simple and not-so-simple cases.

I've been using SQLAlchemy for some time and have found its
combination of "make the simple cases simple" and "allow full control
when needed" to be close to ideal. I can use exactly the same
interface to leverage the SQL generation for mundane tasks and to
craft custom weird SQL that I need.

Combine that with active, level-headed maintenance, and comprehensive
documentation, and I don't even need to consider using the ORM layer
:-)

--
\ “Know what I hate most? Rhetorical questions.” —Henry N. Camp |
`\ |
_o__) |
Ben Finney
Jul 29 '08 #5

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

Similar topics

6
by: blueblueblue2005 | last post by:
here is a friend function of Class Array, which has two private data member: int size, int *ptr // Array's public member function to return size int getSize() const { return size; } friend...
5
by: lappy | last post by:
Hello, I have written a small programme to compact an access 97 database. Dim je As New JRO.JetEngine ' Compacts database Data.Mdb to Data2.mdb. je.CompactDatabase...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
17
by: Pam Ammond | last post by:
I need to use Microsoft Access Automation within a Visual Studio 2003 program written in C# for Windows Forms. When a button is clicked in my VS.NET program, I want it to run a Microsoft Access...
2
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
9
by: Lee | last post by:
Hi all, We need to create a page where we detect the finish of a game that's hosted on another site. We thought of doing it with frames, where we would put the game in an iframe that is...
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.