Re: [Libdbi-drivers-devel] sqlite driver problem?

2008-07-26 Thread Markus Hoenicka
Balazs Scheidler writes:
  This sounds doable, however I potentially have hundreds of tables in the
  database, I'd prefer avoiding having to list all tables when I need to
  open a new one.
  

This is, admittedly, inconvenient.

  Hmm, I tried but sqlite reports an error:
  sqlite create table aaa (a,b,c);
  sqlite alter table aaa add d;
  SQL error: duplicate column name: d

This looks really screwed. I looked into the SQLite3 interface again
to see whether we'd get at more information if we stop using the
sqlite3_get_table() function which is just a wrapper around some
low-level interface. However, that interface is implemented using
callbacks which receive the row data and the row metadata (column
names and such). That is, no rows, no metadata.

However, there is a PRAGMA table_info(table_name) which may come in
handy at this point. We'd have to run a query using this PRAGMA
whenever a query returns 0 rows to manually fix the column number in
the (empty) libdbi result set. I'll check whether this is doable.

regards,
Markus

-- 
Markus Hoenicka
[EMAIL PROTECTED]
(Spam-protected email: replace the quadrupeds with mhoenicka)
http://www.mhoenicka.de

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel


[Libdbi-drivers-devel] sqlite driver problem?

2008-07-20 Thread Balazs Scheidler

Hi,

I've been using libdbi in syslog-ng to insert log data into SQL
databases. I've an issue with the sqlite driver though:

when the result is an empty set, it does not return the column headers -
unlike other drivers -, and this causes problems with syslog-ng.

To describe the problem I have to give some detail how syslog-ng uses
SQL, but please bear with me:

syslog-ng creates tables for itself automatically, so if a table does
not exist, or does not have the required columns, it creates it or adds
the needed columns.

For this it needs to detect whether a table exists, using this simple
query:

SELECT * FROM table WHERE 0=1

MySQL, PgSQL, MSSQL and Oracle returns an empty result set, with the
column information in it. SQLite on the other hand returns no rows and
no columns either.

I don't really know sqlite internals and neither do I know libdbi driver
internals, but I was wondering whether this behaviour can be worked
around in libdbi, or it is something that I have to live with, and the
query above is not a generic, database independent way of finding out
table structure?

Thanks in advance,

-- 
Bazsi



-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel