1. Open the required database.
2. Run the sqlquestion
   select * from sqlite_master;

you get a declaration of table,namn and types.
// Anders


sqlite skrev:
Roger Binns wrote:

The types point still baffles me.  If your code already
knows which column it is dealing with then surely the
code should know what type to expect.  (Eg if you are
dealing with a column named 'title' then you would
expect a string)


Let me explain what I was doing...

I was making a C++ wrapper for a generic "SQL query",
thinking that I could map it to various database engines
as needed in the future.

The results of the query were being returned in two parts,
a list of columns and the results themselves as an array.

In the list of columns it seemed natural to include the
type of the column. That doesn't seem too weird to me.

As this isn't possible I changed it so the data type
is in the result array, not the columns. The column
info is now reduced to "name" and "declared type".

PS: I'm also quite new to SQL and was under the illusion
that data types would be standardized. After checking
a couple of them I see this isn't so, maybe SQLite's
approach is more sensible.

> Do people using your code go around
> randomly changing the database
> schema and the values stored without changing the
> corresponding C code?
>

Noted. If you don't know what's in the table then
you shouldn't be writing to it.

If you're only reading the table then it makes more
sense to have the type on a per-entry basis (even
if it's only so you so you can have a "null" value).






Reply via email to