Advertisement
Shiny_

Untitled

Jun 27th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. SQLite  = dbConnect("sqlite", "sqlite.db")
  2. MySQL   = dbConnect("mysql", "localhost", "root")
  3.  
  4. SQLiteQuery = dbQuery(SQLite, "BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS 'Test' (Kolumna_1 TEXT, Kolumna_2 INTEGER, Kolumna_3 TEXT);")
  5. MySQLQuery  = dbQuery(MySQL, "CREATE TABLE IF NOT EXISTS Test (Kolumna_1 TEXT, Kolumna_2 INT(2), Kolumna_3 TEXT);")
  6.  
  7. function Insert_Record(text, ID, text_2)
  8.     local QueryHandleSQLite = dbQuery(SQLite, "INSERT INTO 'Test' VALUES('?, ?, ?');", text, ID, text_2);
  9.     local QueryHandleMySQL  = dbQuery(MySQL, "INSERT INTO 'Test' VALUES('?, ?, ?');", text, ID, text_2);
  10. end
  11.  
  12. function Fill_Tables()
  13.     local now = getTickCount()
  14.     for i = 0, 10000 do
  15.         Insert_Record("ID I: " .. i, i, "ID II: " ..i)
  16.     end
  17.     local diff = getTickCount() - now;
  18.     outputDebugString("Pomyślnie wypełniono tabelę 10000 debilizmów w czasie " .. diff .. ".")
  19. end
  20.  
  21. function Select()
  22.     local now = getTickCount()
  23.     local QueryHandleSQLite = dbQuery(SQLite, "COMMIT; SELECT Kolumna_1 FROM 'Test';")
  24.     local QueryHandleSQLite = dbQuery(MySQL, "SELECT Kolumna_1 FROM 'Test';")
  25.     local diff = getTickCount() - now;
  26.     outputDebugString("Pomyślnie wybrano 10000 debilizmów z tabeli w czasie " .. diff .. ".")
  27. end
  28.  
  29. addCommandHandler("insert", Fill_Tables)
  30. addCommandHandler("show", Select)
  31.    
  32.     --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement