bonjour
je me connecte à une base de données interbase/firebird en utilisant,
KinterbasDB http://kinterbasdb.sourceforge.net/ pour ceux que ca interesse
mais je pense que le probleme est le meme quel que soit la bdd
j'aimerais acceder a un champs par sont nom plutot que par son index
dans le record en cours, comme je fais maintenent
la prop description du curseur renvoye le tuple de tuple suivant
(('PATIENTID', <type 'str'>, 180, 180, 0, 0, True),
('ORIGINALPATIE NTID', <type 'str'>, 60, 60, 0, 0, True), ('CENTERID',
<type 'int'>, 11, 4, 0, 0, True), ('NAME', <type 'str'>, 452, 452, 0, 0,
True), ('FIRSTNAME', <type 'str'>, 452, 452, 0, 0, True), ('BIRTH',
<type 'int'>, 6, 2, 0, 0, True), ('SEXE', <type 'int'>, 6, 2, 0, 0,
True), ('ENTRYDATE', <type 'DateTime'>, 10, 4, 0, 0, True), ('COMMENTS',
<type 'str'>, 0, 8, 0, 2, True), ('LASTMODIFDATE ', <type 'DateTime'>,
10, 4, 0, 0, True), ('DEP', <type 'int'>, 6, 2, 0, 0, True),
('QUESTIOID', <type 'int'>, 11, 4, 0, 0, True), ('CREADATE', <type
'DateTime'>, 22, 8, 0, 0, True))
le row courant est lui un tuple simple:
('02-0000', None, 2, None, None, 1961, 1, <DateTime object for
'2002-06-16 00:00:00.00' at 90c860>, 'sevrage effectu\xe9\x00 \x00',
<DateTime object for '2002-07-16 00:00:00.00' at 932f20>, None, 520,
<DateTime object for '2004-07-05 00:00:00.00' at 91f4e0>)
comment, par exemple, acceder au 3em element du tuple (en l'occurence le
nombre 2) en utilisant le nom CENTERID qui est le premier element du
3eme element du tuple qui decrit la strucure ?
j'espere que je me suis fais comprendre
merci d'avance...
-- http://www.rootsaka.com 1 2151
richard <ri*****@nullpa rt.org> wrote in message news:<ch******* ***@reader1.ima ginet.fr>... bonjour
je me connecte à une base de données interbase/firebird en utilisant, KinterbasDB http://kinterbasdb.sourceforge.net/ pour ceux que ca interesse
mais je pense que le probleme est le meme quel que soit la bdd
j'aimerais acceder a un champs par sont nom plutot que par son index dans le record en cours, comme je fais maintenent
la prop description du curseur renvoye le tuple de tuple suivant (('PATIENTID', <type 'str'>, 180, 180, 0, 0, True), ('ORIGINALPATIE NTID', <type 'str'>, 60, 60, 0, 0, True), ('CENTERID', <type 'int'>, 11, 4, 0, 0, True), ('NAME', <type 'str'>, 452, 452, 0, 0, True), ('FIRSTNAME', <type 'str'>, 452, 452, 0, 0, True), ('BIRTH', <type 'int'>, 6, 2, 0, 0, True), ('SEXE', <type 'int'>, 6, 2, 0, 0, True), ('ENTRYDATE', <type 'DateTime'>, 10, 4, 0, 0, True), ('COMMENTS', <type 'str'>, 0, 8, 0, 2, True), ('LASTMODIFDATE ', <type 'DateTime'>, 10, 4, 0, 0, True), ('DEP', <type 'int'>, 6, 2, 0, 0, True), ('QUESTIOID', <type 'int'>, 11, 4, 0, 0, True), ('CREADATE', <type 'DateTime'>, 22, 8, 0, 0, True))
le row courant est lui un tuple simple: ('02-0000', None, 2, None, None, 1961, 1, <DateTime object for '2002-06-16 00:00:00.00' at 90c860>, 'sevrage effectu\xe9\x00 \x00', <DateTime object for '2002-07-16 00:00:00.00' at 932f20>, None, 520, <DateTime object for '2004-07-05 00:00:00.00' at 91f4e0>)
comment, par exemple, acceder au 3em element du tuple (en l'occurence le nombre 2) en utilisant le nom CENTERID qui est le premier element du 3eme element du tuple qui decrit la strucure ?
j'espere que je me suis fais comprendre
merci d'avance...
Salut Richard,
je fais quelque-chose de tres semblable. Mon idee est la suivante
(attention, je tape tout de tete et je te laisse le soin de tester
toi-meme):
# d'abord il faut extraire une list de tous les noms:
names = [ x[0] for x in cursor_descript ion ]
# ensuite tu bricoles un dictionnaire avec le row courant:
row = dict(zip(names, current_row))
# tu peux maintenant faire les acces suivants:
center_id = row["CENTERID"]
first_name = row["FIRSTNAME"]
# etc...
Un derniere remarque: la langue officielle de comp.lang.pytho n est
l'anglais. Tu auras donc beaucoup plus de succes si tu traduis tes
messages avant de les envoyer...
Bonne chance,
Jan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Raymond Hettinger |
last post by:
Please comment on the new PEP for reverse iteration methods.
Basically, the idea looks like this:
for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0
<do something with i>
The HTML version is much more readable than the ReST version.
See:
http://www.python.org/peps/pep-0322.html
|
by: Raymond Hettinger |
last post by:
Peter Norvig's creative thinking triggered renewed interest in PEP 289.
That led to a number of contributors helping to re-work the pep details
into a form that has been well received on the python-dev list:
http://www.python.org/peps/pep-0289.html
In brief, the PEP proposes a list comprehension style syntax for
creating fast, memory efficient generator expressions on the fly:
sum(x*x for x in roots)
|
by: Raymond Hettinger |
last post by:
Based on your extensive feedback, PEP 322 has been completely revised.
The response was strongly positive, but almost everyone preferred
having a function instead of multiple object methods. The updated
proposal is at:
www.python.org/peps/pep-0322.html
In a nutshell, it proposes a builtin function that greatly simplifies reverse
iteration. The core concept is that clarity comes from specifying a
sequence in a forward direction and...
|
by: seberino |
last post by:
Tuples are defined with regards to parentheses ()'s as everyone knows.
This causes confusion for 1 item tuples since (5) can be interpreted
as a tuple OR as the number 5 in a mathematical expression
such as x = (5) * (4+6).
Wouldn't it have been better to define tuples with <>'s or {}'s or
something else to avoid this confusion??
Perhaps ()'s are a good idea for some other reason I don't know?
|
by: Luis P. Mendes |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm trying to solve this problem:
suppose I'm reading a csv file and want to create a tuple of all those
rows and values, like ((row1value1, row1value2, row1value3),(row2value1,
row2value2, row2value3),..., (rowNvalue1, rowNvalue2, rowNvalue3))
| |
by: Icare-Infographie |
last post by:
bonjour,
j ai un textbox qui reçoit un contenu de champ de base de donnees;
quand je modifie ce champ, la modification n est pas pris en compte dans la
mise à jourde la bd.
si je supprime le databind() du textbox cette modification est executée,
par contre au depart mon textbox n est plus documenté.
|
by: C.L. |
last post by:
I was looking for a function or method that would return the index to the first
matching element in a list. Coming from a C++ STL background, I thought it might
be called "find". My first stop was the Sequence Types page of the Library
Reference (http://docs.python.org/lib/typesseq.html); it wasn't there. A search
of the Library Reference's index seemed to confirm that the function did not
exist. A little later I realized it might be called...
|
by: seberino |
last post by:
Please help me think of an example where immutable tuples are
essential.
It seems that everywhere a tuple is used one could just as easily use
a list instead.
chris
|
by: =?utf-8?B?TWFjaWVqIEJsaXppxYRza2k=?= |
last post by:
Hi Pythonistas!
I've got a question about storing tuples in a dictionary. First, a
small test case which creates a list of dictionaries:
import time
list_of_dicts =
keys =
prev_clk = time.clock()
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
| |