Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 22nd, 2004, 11:56 AM
bquad20 bquad20 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 13 bquad20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Database Help For Newbie

I am trying to select * from a database table and format the
"SQL Time Stamp" in the list I am building using a for loop.
When I run the code below, I get <DbiDate object at 0x008AE120> for the START_TIME and END_TIME.

My question(s):
- Is there way to format the date? If so, how?
AND/OR
- Is there a way to select individual fields from the
result set, not just fetchall() or fetchmany(x)?


Code:
import dbi, odbc

global jobsD
jobsD = [] 

def parseItDAO(): 
try:
conn    = odbc.odbc('myOracle/user/pass')
c       = conn.cursor()
sql     = "select field1,START_TIME,END_TIME,field4 from table_name"
c.execute(sql)
                
#for x in c.fetchall():
for x in c.fetchmany(5):
jobsD.append(x)

conn.commit()
c.close()
conn.close()

return jobsD
  
except NameError,e:
print 'error ', e

Reply With Quote
  #2  
Old July 27th, 2004, 03:50 PM
bquad20 bquad20 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 13 bquad20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
re: Database Help For Newbie

I found the answers to get this issue solved. I will answer my own questions for future reference for anyone who needs it:
- Is there way to format the date? If so, how?
- Is there a way to select individual fields from a result set

To format a database time stamp (SQL), you need to convert
the time to string, after you select each field from the
db table as follows:

Code:
#for field1,START_TIME,END_TIME,field4 in c.fetchall(5):
for field1,START_TIME,END_TIME,field4 in c.fetchmany(5):
jobsD.append(field1) jobsD.append(str(START_TIME)) jobsD.append(str(END_TIME)) jobsD.append(field4)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Database Help For Newbie


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT