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

odbc and accessing database results by field

JZ
import odbc
conn = odbc.odbc('mydsn')
c = conn.cursor()
c.execute('SELECT TOP 10 field1, field2 FROM TABLE')
rows = c.fetchall()
c.close()
conn.close()

I am using MSSQL2000. My problem is:
Instead of row[0], rows[1]
I would like to use row['field1], row['field']
Is it possible for odbc module?
I cannot find any comprehensive documentation :(

--
JZ ICQ:6712522

Jul 18 '05 #1
1 2938

"JZ" <jr*******@jngpugbjreQBGbet.cy> wrote in message
news:hc********************************@4ax.com...
import odbc
conn = odbc.odbc('mydsn')
c = conn.cursor()
c.execute('SELECT TOP 10 field1, field2 FROM TABLE')
rows = c.fetchall()
c.close()
conn.close()

I am using MSSQL2000. My problem is:
Instead of row[0], rows[1]
I would like to use row['field1], row['field']
Is it possible for odbc module?
I cannot find any comprehensive documentation :(


Well, I've been using oledb, but it should be fairly similar.

I just wrote a small wrapper class for the ADODB.Recordset object, that when
its Open() method is called, (as well as MoveNext, MovePrev, etc.) it copies
the current field names and their values into self.__dict__, so I can access
them via r.Field1, r.Field2, etc.

Another route I've gone (since OS/400 allows field names like TEST#REC@,
which python pukes on, is to over-ride __call__ to handle field data. (i.e.
c('test') = somevalue, etc.).

Anyways, a couple of ideas.
Jul 18 '05 #2

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

Similar topics

13
by: Graham | last post by:
I need a SQL Server or ODBC package for Python. Can anyone help please? Have search the Python packages under Database and there is no reference to either SQL Server or ODBC. Thanks Graham
3
by: Ian | last post by:
We are currently experiencing problems with our Access XP database. We are using access as the front-end and are connecting to Oracle 7.3 via ODBC. Our users are running Win 98 and Win Xp. We are...
0
by: Julia Baresch | last post by:
Everyone, I posted the message below back in February and didn't get any information. I also wasn't able to find any documentation in MS Help, web site, or other groups. I'm posting now with...
8
by: Alfonso Esteban Gonzalez Sencion | last post by:
I am trying to use Access as a front end for extracting information from an Oracle database. I started using linked tables but I am getting a very curious behaviour. When I consult the linked...
7
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
1
by: erick-flores | last post by:
Hello all I have a linked table using ODBC. When I tried to do Count() and Sum() for this linked table (onw of the field in the table is name "total") the form takes forever to gives me the...
8
by: Neil | last post by:
I just started using Access 2003, and I can't link a SQL Server table. I right-click on the database window; select Link Tables; and select ODBC Databases from the Files of Type dropdown. As soon...
5
by: cj2 | last post by:
This code works: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Linq; using System.Web; using System.Web.Services; using...
4
BeemerBiker
by: BeemerBiker | last post by:
I can create an access database with a colon in the field name, but I cant access it. I tried escaping the colon with single, double quotes and the backslash but didnt find a combo that worked. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
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...

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.