kniterbasdb and datetime

L

Laszlo Nagy

Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # See
http://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mxdatetime_required

Then I try to update the database:

sql = "UPDATE TABLE1 SET DATEFIELD=? where ID = ?"
params=[datetime.date(2007,11,01),2341]
cursor.execute(sql,params)

I get this error:

kinterbasdb.ProgrammingError: (-413, 'isc_dsql_execute: \n conversion
error from string "2007-11-01"')

What is wrong here?

Thanks,

Laszlo
 
D

DarkBlue

Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # Seehttp://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mx...

Then I try to update the database:

sql = "UPDATE TABLE1 SET DATEFIELD=? where ID = ?"
params=[datetime.date(2007,11,01),2341]
cursor.execute(sql,params)

I get this error:

kinterbasdb.ProgrammingError: (-413, 'isc_dsql_execute: \n conversion
error from string "2007-11-01"')

What is wrong here?

Thanks,

Laszlo


Kinterbasdb probably expects the format looking like

month/day/year

rather than

year-month-day


I have an old pythoncard app where there was the same issue
when picking a date using the wx.calendar widget,
Rearranging the format solved the problem.

here is the relevant code snippet ,maybe it gives you the idea:

def on_doCalDate_command(self,event):
# this the way to get a wx.calendar date into a
# format suitable for kinterbasdb

D=[]
MYDATE=str(self.components.Calendar1.date)
SPLITDATE=MYDATE.split('-')
for data in SPLITDATE:
D.append(data)
YR=D[0]
MO=D[1]
DY=D[2]
JOBDATE=MO+"/"+DY+"/"+YR




DB
 
L

Laszlo Nagy

DarkBlue írta:
Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # Seehttp://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mx...

Then I try to update the database:

sql = "UPDATE TABLE1 SET DATEFIELD=? where ID = ?"
params=[datetime.date(2007,11,01),2341]
cursor.execute(sql,params)

I get this error:

kinterbasdb.ProgrammingError: (-413, 'isc_dsql_execute: \n conversion
error from string "2007-11-01"')

What is wrong here?

Thanks,

Laszlo


Kinterbasdb probably expects the format looking like

month/day/year

rather than

year-month-day
It is not that. The parameter passed to cursor.execute() is a
datetime.datetime instance. It is not a string, so if there is a
formatting problem then it must be inside kinterbasdb. (How would you
control the format if you have no string representation?)

However, I'm 100% sure that others are also using this module and
probably there is something that I should change, just don't know what
it is.

Thanks,

Laszlo
 
L

Laszlo Nagy

All right, I tried the month/day/year version:

print sql
print params
cur.execute(sql,params)

Results in:

Inserting new TTT codes...insert into ttt(

ID,
TTT,
KIHIR
) VALUES (
GEN_ID(G_TTT,1),
?,?)
[210227753, '11/1/2007']
Traceback (most recent call last):
File "c:\Delphi5_Brinkman\Projects\TTTImport\tttupdate.py", line 131,
in <module>
cur.execute(sql,params)
kinterbasdb.ProgrammingError: (-413, 'isc_dsql_execute: \n conversion
error from string "2007-11-01"')


You see, I passed '11/1/2007' but the error says "2007-11-01". So what?

I also tried this:


Inserting new TTT codes...insert into ttt(

ID,
TTT,
KIHIR
) VALUES (
GEN_ID(G_TTT,1),
?, cast( ? as date) )
[210227753, '11/1/2007']

Results in:


Traceback (most recent call last):
File "c:\Delphi5_Brinkman\Projects\TTTImport\tttupdate.py", line 131,
in <modu
le>
cur.execute(sql,params)
kinterbasdb.ProgrammingError: (-804, 'isc_dsql_prepare: \n Dynamic SQL
Error\n
SQL error code = -804\n Data type unknown')

Right now I cannot see any way to specify a date parameter and as time
goes by, it is becoming a biger problem for me. :-(

Please help.

Laszlo
 
U

Uwe Grauer

Laszlo said:
Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # See
http://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mxdatetime_required


Then I try to update the database:

sql = "UPDATE TABLE1 SET DATEFIELD=? where ID = ?"
params=[datetime.date(2007,11,01),2341]
cursor.execute(sql,params)

I get this error:

kinterbasdb.ProgrammingError: (-413, 'isc_dsql_execute: \n conversion
error from string "2007-11-01"')

What is wrong here?

Thanks,

Laszlo

Just tested this against my 2.03 firebird db:

import datetime
import kinterbasdb as db

db.init(type_conv=200)
con = db.connect(dsn='myhost:fbtool-dev', user='sysdba', password='pwd')
sql = "update jnp set gebdat = ? where iid = ?"
params = [datetime.date(2007, 11, 01), 1000052]
cur = con.cursor()
cur.execute(sql,params)
con.commit()

It worked.
What version of kinterbasdb are you using?

Uwe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top