Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Connection = dbConnect("sqlite", "sqlite.db")
- local TABELA = "TABELA"
- local HandleQuery = dbQuery(Connection, "CREATE TABLE IF NOT EXISTS " .. TABELA .. " (Tekst TEXT, ID INTEGER)")
- local Handler_DB = nil
- local Number = 250000
- local MySQL_HOST = "46.4.177.235"
- local MySQL_USER = "Linux_Shines"
- local MySQL_PASS = "test"
- local MySQL_DB = "Linux_Shines"
- local MySQL_PORT = 3306
- addEventHandler("onResourceStart", resourceRoot, function()
- MySQLConnection = dbConnect("mysql", "dbname=" .. MySQL_DB .. ";host=" .. MySQL_HOST, MySQL_USER, MySQL_PASS, "share=1", "port=" .. MySQL_PORT)
- MySQLQuery = dbQuery(MySQLConnection, "CREATE TABLE IF NOT EXISTS Test (Kolumna_1 TEXT, Kolumna_2 INT(2), Kolumna_3 TEXT);")
- local NOW = getTickCount()
- for i = 0, Number do
- print()
- end
- local TIME__ = getTickCount() - NOW
- outputDebugString("Czas wykonania pętli - " .. TIME__ .. " milisekund.", 3)
- if not Connection then
- outputDebugString("Brak połączenia z bazą danych.", 1)
- else
- outputDebugString("Połączono z bazą danych.", 3)
- Fill_Table()
- Show_Table()
- end
- end)
- function Fill_Table()
- local NOW = getTickCount()
- for i = 0, Number do
- SQLite_Query = dbQuery(Connection, "INSERT INTO " .. TABELA .. " (Tekst, ID) VALUES (?, ?)", "Tekst nr" .. i, i)
- end
- local Difference = getTickCount() - NOW
- outputDebugString("Pomyślnie wypełniono tabelę w SQLite. Czas trwania to " .. Difference .. " milisekund", 3)
- local NOW__ = getTickCount()
- for i__ = 0, Number do
- MySQL_Query = dbQuery(Connection, "INSERT INTO " .. TABELA .. " (Tekst, ID) VALUES (?, ?)", "Tekst nr" .. i__, i__)
- end
- local Difference__ = getTickCount() - NOW__
- outputDebugString("Pomyślnie wypełniono tabelę w MySQL. Czas trwania to " .. Difference__ .. " milisekund", 3)
- end
- function Show_Table()
- local NOW = getTickCount()
- local QUERY__ = dbQuery(Connection, "SELECT ID FROM " .. TABELA .. " WHERE ID > 0 AND ID < 100")
- local Result = dbPoll(QUERY__, -1)
- local Difference = getTickCount() - NOW
- outputDebugString("Pomyślnie wybrano z tabeli. Czas trwania dla SQLite to " .. Difference .. " milisekund", 3)
- local NOW__ = getTickCount()
- local QUERY____ = dbQuery(Connection, "SELECT ID FROM " .. TABELA .. " WHERE ID > 0 AND ID < 100")
- local Result = dbPoll(QUERY____, -1)
- local Difference__ = getTickCount() - NOW__
- outputDebugString("Pomyślnie wybrano z tabeli. Czas trwania dla MySQL to " .. Difference__ .. " milisekund", 3)
- end
- addCommandHandler("insert", Fill_Table)
- addCommandHandler("show", Show_Table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement