Recent

Author Topic: [Sqlite3]How to get tabe info?  (Read 371 times)

Borneq

  • Full Member
  • ***
  • Posts: 238
[Sqlite3]How to get tabe info?
« on: January 03, 2020, 01:10:52 pm »
Get all tables (but without system tables):
SELECT * FROM sqlite_master where type='table'
but how to get column names and types of columns?

Borneq

  • Full Member
  • ***
  • Posts: 238
Re: [Sqlite3]How to get tabe info?
« Reply #1 on: January 03, 2020, 01:58:07 pm »
Code: Pascal  [Select][+][-]
  1.   rc := sqlite3_prepare_v2(pDb, 'pragma table_info (sqlite_master)', -1, @stmt, nil);
  2.   if rc=SQLITE_OK then
  3.   begin
  4.     //will continue to go down the rows (columns in your table) till there are no more
  5.     while sqlite3_step(stmt) = SQLITE_ROW do
  6.     begin
  7.         writeln(sqlite3_column_text(stmt, 1));
  8.         writeln(sqlite3_column_text(stmt, 2));
  9.         //do something with colName because it contains the column's name
  10.     end;
  11.   end;
  12.  
after https://stackoverflow.com/questions/947215/how-to-get-a-list-of-column-names-on-sqlite3-database

 

TinyPortal © 2005-2018