473,227 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,227 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 1482
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Max M | last post by:
# -*- coding: latin-1 -*- """ I am currently using the datetime package, but I find that the design is oddly asymmetric. I would like to know why. Or perhaps I have misunderstood how it...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
3
by: Andrew S. Giles | last post by:
Hello, I am importing a flat text file, and putting it into a datagrid for display on a form. Currently the users have their dates and times seperated. I have two fields, therefore in the...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
5
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

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.