Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Mar 2004 14:46:31 -0500
From:      "Armstrong, Paul" <Paul.Armstrong@cognos.com>
To:        "'perky@FreeBSD.org'" <perky@FreeBSD.org>
Cc:        "'ports@FreeBSD.org'" <ports@FreeBSD.org>
Subject:   FreeBSD Port: py-mssql-0.5.1
Message-ID:  <FB15E670DA55D51185350008C786514A13CD9BA1@sottexch1.cognos.com>

next in thread | raw e-mail | index | archive | help
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C415C6.88D245EA
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,
I am using python2.2.3 with a mssql database and
pymssql-0.5.1.win32-py2.2.exe. I am having trouble getting dates out of =
the
database. I created a test datbase that has only two fields, datetime =
and
smalldatetime.
Below is the code I am using with the output displayed. Could you help =
me. I
really need to get this going.
Any help is appreciated.
Thanks
Paul Armstrong, 613-738-1338 ext 5553
=20
program output is
=20
D:\programs\rcserver>python date.py
datetime is .20040329 14:44:49.
row[0] is .=A6=F6.
row[1] is .=A6=F6u?.



This message may contain privileged and/or confidential information.  =
If you
have received this e-mail in error or are not the intended recipient, =
you
may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the =
sender
promptly by e-mail that you have done so.  Thank you.
 =20

------_=_NextPart_000_01C415C6.88D245EA
Content-Type: application/octet-stream;
	name="date.py"
Content-Disposition: attachment;
	filename="date.py"

#!/usr/bin/env python
from sys import argv, exit
from getopt import getopt
from traceback import print_exc
import pymssql
import sys
from time import gmtime, strftime, localtime
#from mx.DateTime import *
import date
import time

def main():
	db = pymssql.connect(host='wottarmstrop2',user='dbo',password='',database='nfsMonitor')
	cursor = db.cursor()
#	date = strftime("%Y-%m-%d %H:%M:%S", localtime())	
#	date = strftime("%Y%m%d %H:%M:%S", localtime())	
#	date = str(now())
	dateToday = strftime("%Y%m%d %H:%M:%S", localtime())	
#	dateToday = localtime()
#	todaydate = date()	
	datetime = dateToday
	smalldatetime = dateToday

#>>> now().strftime()
#'Sun Jun 14 11:08:51 1998'

#	datetime = str(now())
#   '1998-06-14 11:09:17.82'
	print "datetime is .%s." %(datetime)

#	updateCmd = "INSERT INTO test VALUES ( '%s', '%s')" %( datetime,datetime)
#	updateCmd = "INSERT INTO test VALUES ( '%s', '%s')" %( "20040329 10:09:30","20040329 10:09:30")
#	updateCmd = "INSERT INTO test VALUES ( '%s', '%s')" %( datetime,smalldatetime)
#	updateCmd = "INSERT INTO test VALUES ( '%s', '%s')" %( datetime,"20040329 10:09:30")
	updateCmd = "INSERT INTO test VALUES ( '%s', '%s')" %( dateToday,smalldatetime)
	cursor.execute( updateCmd )
	db.commit()

	updateCmd = "SELECT * FROM test"
	cursor.execute( updateCmd )
	currentRunNumber = cursor.fetchall()
	for row in currentRunNumber:
		print "row[0] is .%s." %(row[0])	
		print "row[1] is .%s." %(row[1])	
	
if __name__ == '__main__':
	main()


------_=_NextPart_000_01C415C6.88D245EA--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FB15E670DA55D51185350008C786514A13CD9BA1>