EnglishРусский  

   ..

   read.me

   sqlite3.def

   sqlite3.g

   sqlite3_demo.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\lib\sqlite3\sqlite3_demo.g
  1 #exe = 0
  2 #norun = 0
  3 #gefile = 0
  4 #libdir = %EXEPATH%\lib
  5 #libdir1 = %EXEPATH%\..\lib\vis
  6 #include = %EXEPATH%\lib\stdlib.ge
  7 #wait = 1
  8 /******************************************************************************
  9 *
 10 * Copyright (C) 2009, The Gentee Group. All rights reserved. 
 11 * This file is part of the Gentee open source project - http://www.gentee.com. 
 12 * 
 13 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 14 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 15 * ACCEPTANCE OF THE AGREEMENT.
 16 *
 17 * Author: Alexander Antypenko ( santy )
 18 *
 19 ******************************************************************************/
 20 
 21 include
 22 {
 23  $"sqlite3.g"
 24 }
 25 
 26 func sqlite3_demo <main>
 27 {
 28   sqlite3 demo_data
 29 
 30   print("DEMO SQLITE3 DATABASE FUNCTIONS \n\n")
 31   print("--- open database --- \n\n")
 32 
 33   if (demo_data.open("demo_dat.db")) {
 34    print("database opened/created,  ... Ok \n")
 35   }
 36   else : print("problem opening/creating database \n")
 37   //getch()
 38   print("--- create table --- \n\n")
 39 
 40   if (demo_data.sql_execute("CREATE TABLE test_table (name TEXT, qty INT(3), price REAL(10), blobtext BLOB)"))
 41   {
 42     print("created table test_table,  ... Ok \n")
 43   }
 44   else : print("problem creating table < test_table > \n")
 45 
 46   if (demo_data.sql_execute("CREATE TABLE tst_tbl (name TEXT, qty INT(3), price REAL(10), blobtext BLOB, demo_text TEXT)"))
 47   {
 48     print("created table test_table,  ... Ok \n")
 49   }
 50   else : print("problem creating table < tst_tbl > \n")
 51 
 52 
 53   //getch()
 54   print("--- insert data into exist table --- \n\n")
 55 
 56   if (demo_data.sql_execute("insert into test_table values ('apples', 11, 1.234, X'41424300010101');"))
 57   {
 58     print("inserted, last row id: "+str(demo_data.rowid())+"  ... Ok \n")
 59   }
 60   else : print("problem inserting row \n")
 61   if (demo_data.sql_execute("insert into test_table values ('oranges', 22, 2.345, X'42434400020202');"))
 62   {
 63     print("inserted, last row id: "+str(demo_data.rowid())+"  ... Ok \n")
 64   }
 65   else : print("problem inserting row \n")
 66 
 67   if (demo_data.sql_execute("insert into test_table values ('bananas', 33, 3.456, X'44454600030303');"))
 68   {
 69     print("inserted, last row id: "+str(demo_data.rowid())+"  ... Ok \n")
 70   }
 71   else : print("problem inserting row \n")
 72   if (demo_data.sql_execute("insert into test_table values ('grapes', 123456789012345678, 7.89, X'47484900040404');"))
 73   {
 74     print("inserted, last row id: "+str(demo_data.rowid())+"  ... Ok \n")
 75   }
 76   else : print("problem inserting row \n")
 77   //getch()
 78   print("--- select data from table --- \n\n")
 79 
 80   if (demo_data.sql_execute("select * from test_table;"))
 81   {
 82     uint i,j
 83 
 84     print("selected rows: \n")
 85     fornum i=0,*demo_data.col_val
 86     {
 87       fornum j=0,*demo_data.col_val[i].values
 88       {
 89         print("("+ demo_data.col_val[i].values[j]+") \n") 
 90       }     
 91     }
 92    
 93     print("column names:  \n")
 94     fornum i=0,*demo_data.col_names
 95     {
 96       print("Field -> "+ demo_data.col_names[i]+" \n") 
 97     }
 98   }
 99   else : print("problem selecting rows \n")
100 
101   if (demo_data.sql_execute("delete from test_table where 1;"))
102   {
103     print("deleted, rows affected: "+str(demo_data.changes())+",  ... Ok \n")
104   }
105   else : print("problem deleting rows \n")
106   
107   arrstr asTables
108   if (demo_data.tables(asTables))
109   {
110     uint i
111     fornum i=0, *asTables {
112       print("tables: "+asTables[i]+",  ... Ok \n")
113     }
114   }
115   else : print("problem in tables method \n")
116 
117   arrstr asColumns
118   if (demo_data.columns("test_table",asColumns))
119   {
120     uint i
121     fornum i=0, *asColumns {
122       print("Columns: "+asColumns[i]+",  ... Ok \n")
123     }
124   }
125   else : print("problem in columns method \n")
126   demo_data.beginTrans()
127   if (demo_data.sql_execute("drop table test_table;")) {
128     demo_data.commitTrans()
129     print("table test_table dropped,  ... Ok \n")
130   }
131   else : print("problem dropping table test_table \n")
132 
133 
134   demo_data.close()
135   getch()
136 }
137 
Редактировать