GDate, GdaTimestamp && sqlite

View: New views
3 Messages — Rating Filter:   Alert me  

GDate, GdaTimestamp && sqlite

by Massimo Cora' :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

say I've the following table on sqlite.

create table foo (analyse_time DATE);

and say that I populate its elements with

insert into foo values (datetime ('now', 'localtime'));

A select shows me this:

sqlite> select * from foo;
2009-06-25 01:00:21

But when I'm getting the GValue from the GdaDataModel I cannot use it as
a GdaTimestamp. The only GType detected is GDate, but I need the time too.

How can be performed that?
Right now I'm using an hack like

select analyse_time||'' as analyse_time_str from foo;

which is seen as a parseable string.
I'm using libgda git head.

thanks and regards,
Massimo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpCsP8ACgkQcfVTgMRILk0ikQCeOmhFEDygUost7Rqk4iRJXmSi
GlIAoIb2JMMJhM9tNPo7A7jQR4OCZZhW
=/Ka2
-----END PGP SIGNATURE-----
_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDate, GdaTimestamp && sqlite

by Vivien Malerba :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2009/6/25 Massimo Cora' <maxcvs@...>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

say I've the following table on sqlite.

create table foo (analyse_time DATE);

and say that I populate its elements with

insert into foo values (datetime ('now', 'localtime'));

A select shows me this:

sqlite> select * from foo;
2009-06-25 01:00:21

But when I'm getting the GValue from the GdaDataModel I cannot use it as
a GdaTimestamp. The only GType detected is GDate, but I need the time too.

2 solutions:
* if you can, use the timestamp type instead of date in the table declaration: create table foo (analyse_time timestamp);
* specifically request that the GType for the "analyse_time" column must be GDA_TYPE_TIMESTAMP when running the SELECT statement, using gda_connection_statement_execute_select_full()

Regards,

Vivien


_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Re: GDate, GdaTimestamp && sqlite

by Massimo Cora' :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Vivien Malerba wrote:
>
> 2 solutions:
> * if you can, use the timestamp type instead of date in the table
> declaration: create table foo (analyse_time timestamp);
> * specifically request that the GType for the "analyse_time" column must
> be GDA_TYPE_TIMESTAMP when running the SELECT statement, using
> gda_connection_statement_execute_select_full()
>

thanks, the second solution worked very well

regards,
Massimo


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpDp8IACgkQcfVTgMRILk0vTgCeNL3qm4DnZ1b5kWH3aabTR3sx
1GUAni9dJXE6X3O7OumHS0rf9/ETbjq1
=5LXh
-----END PGP SIGNATURE-----
_______________________________________________
gnome-db-list mailing list
gnome-db-list@...
http://mail.gnome.org/mailman/listinfo/gnome-db-list