Is there any way to retrieve column names from a cursor using the ODBC
module? Or must I, in advance, create a dictionary of column position
and column names for a particular table before I can access column
values by column names? I'd prefer sticking with the ODBC module for
now because it comes standard in Python.
I'm using Python 2.4 at the moment.
Thanks. 5 8321
On Jun 21, 11:58 pm, dana...@yahoo.c om wrote:
Is there any way to retrieve column names from a cursor using the ODBC
module? Or must I, in advance, create a dictionary of column position
and column names for a particular table before I can access column
values by column names? I'd prefer sticking with the ODBC module for
now because it comes standard in Python.
I'm using Python 2.4 at the moment.
Thanks.
On Jun 21, 11:58 pm, dana...@yahoo.c om wrote:
Is there any way to retrieve column names from a cursor using the ODBC
module? Or must I, in advance, create a dictionary of column position
and column names for a particular table before I can access column
values by column names? I'd prefer sticking with the ODBC module for
now because it comes standard in Python.
I'm using Python 2.4 at the moment.
Do you mean the odbc module? If so, it doesn't come standard in
Python; it's part of the win32 package.
I haven't used it for years -- my preference on Windows these days
would be mxODBC if the client would pay the licence fee, otherwise
pyodbc. Sorry I'm not answering your question ... perhaps you should
be asking a different question :)
Cheers,
John
On Jun 22, 12:19 am, John Machin <sjmac...@lexic on.netwrote:
On Jun 21, 11:58 pm, dana...@yahoo.c om wrote:
Is there any way to retrieve column names from a cursor using the ODBC
module? Or must I, in advance, create a dictionary of column position
and column names for a particular table before I can access column
values by column names? I'd prefer sticking with the ODBC module for
now because it comes standard in Python.
I'm using Python 2.4 at the moment.
Do you mean the odbc module? If so, it doesn't come standard in
Python; it's part of the win32 package.
I haven't used it for years -- my preference on Windows these days
would be mxODBC if the client would pay the licence fee, otherwise
pyodbc. Sorry I'm not answering your question ... perhaps you should
be asking a different question :)
Cheers,
John
But to help you answer your question: if the module that you are using
supports the 2.0 version of the database API (see http://www.python.org/dev/peps/pep-0249/),
then it will support the cursor.descript ion attribute, which gives you
not only the name but the type and 5 other bits of info about each
column. If it doesn't, I'd suggest moving on.
HTH,
John
On Jun 21, 3:58*pm, dana...@yahoo.c om wrote:
Is there any way to retrieve column names from a cursor using the ODBC
module? Or must I, in advance, create a dictionary of column position
and column names for a particular table before I can access column
values by column names? I'd prefer sticking with the ODBC module for
now because it comes standard in Python.
I'm using Python 2.4 at the moment.
Thanks.
You should be able to do
column_names = [d[0] for d in cursor.descript ion]
Thanks Chris and John. Chris, this worked perfectly with the ODBC
module that ships with Python Win32:
column_names = [d[0] for d in cursor.descript ion]
John, I've never heard of pyodbc but I'll have to look into it.
Thanks again.
Dana This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Ferber |
last post by:
Hi,
I can't find any good documentation about the Python-database module, all I
found was this rudimentary (no examples, no references) piece here:
http://www.python.org/peps/pep-0249.html
Anyway, this and also this tutorial here:
http://www.devshed.com/c/a/Python/MySQL-Connectivity-With-Python/2/
|
by: Philip Mette |
last post by:
I am begginner at best so I hope someone that is better can help.
I have a stored procedure that updates a view that I wrote using 2
cursors.(Kind of a Inner Loop) I wrote it this way Because I couldn't
do it using reqular transact SQL.
The problem is that this procedure is taking longer and longer to run.
Up to 5 hours now! It is anaylizing about 30,000 records. I think
partly because we add new records every month.
The procedure...
|
by: s99999999s2003 |
last post by:
hi
the database "execute" function returns a list of logical results. Each
logical result is a list of row tuples, as explained in the documents.
everytime i use it to execute various statements, it returns me, for
example
(, , ) and sometimes , (, ) or ()
in my call, i give
eg (a,b,c) = db.execute(stmt) so that it returns me (, ,
|
by: Joe |
last post by:
Hi All,
I am new to using the Access DB and I need some help if someone
is able to give it to me. What I want to do is get the names of
the columns of certain tables. Not the data in the table but the
table column names.
I've seen other posts that suggest using the SQL command DESCRIBE
but I can't get it to work for some reason. Other posts have code
samples but they're written in VB which I am not familiar with. I
|
by: ssb |
last post by:
Hello,
This may be very elementary, but, need help because I am new to access
programming.
(1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor
?) the values one by one and populate a combo box with these names.
(this way, I can display all the EMPLOYEE_NAME values)
(2) In general, can I do additional processing on column values from
| |
by: Larry Bird |
last post by:
I've created a AlertDataClass below within the class I have tables and column that I've create. In the AlertDataAccess class I'm trying to insert data into my tables. AlertDataAccess is a Module that is trying to insert data into the tables. Within the AlertDataClass is subroutine that init and creates ColumnNames. In invoke the AddDataColumnNames() sub to create the column headers.
Why can't I see the column names in my module that I'm...
|
by: Mythran |
last post by:
I wrote some code that is supposed to enumerate through the specified file's
win32 resources and return a string-array of all icon names. When it runs,
it returns a string-array with a bunch of numbers in sequential order (1-55
when ran against iexplore.exe).
When I open up iexplore.exe in Visual Studio, I see 23 icons. Each icon has
1 or more sizes of the icon...I'm assuming that there are, in fact, 55 icon
resources in iexplore.exe,...
|
by: A.M |
last post by:
Hi
I use a code similar to this to retrieve data from Oracle database:
import cx_Oracle
|
by: jeoffh |
last post by:
Background:
I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete some values while leaving the other values alone. I am designing this database/table/column so maybe I could use attributes or elements/nodes, the choice is ultimately mine. The one constraint is that I have to allow for customized name/value pairs....
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |