471,337 Members | 1,012 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

kniterbasdb and datetime


Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # See
http://kinterbasdb.sourceforge.net/d...etime_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

Dec 13 '07 #1
4 1413
On Dec 13, 7:45 pm, Laszlo Nagy <gand...@shopzeus.comwrote:
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

Dec 13 '07 #2
DarkBlue írta:
On Dec 13, 7:45 pm, Laszlo Nagy <gand...@shopzeus.comwrote:
> 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

Dec 13 '07 #3
>Kinterbasdb probably expects the format looking like

month/day/year

rather than

year-month-day
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

Dec 13 '07 #4
Laszlo Nagy wrote:
>
Hi All,

I connected to a FireBird 1.5 database this way:

import kinterbasdb
kinterbasdb.init(type_conv=200) # See
http://kinterbasdb.sourceforge.net/d...etime_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
Dec 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Max M | last post: by
15 posts views Thread by Fritz Switzer | last post: by
3 posts views Thread by Andrew S. Giles | last post: by
6 posts views Thread by Ante Perkovic | last post: by
5 posts views Thread by I am Sam | last post: by
11 posts views Thread by Cor Ligthert | last post: by
9 posts views Thread by Phil B | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.