Creating a table in server SQLite database.

Hello
How I can create a table in the server database using SQLite? I tried to do so, but nothing came of it:
[lua]
if SERVER then
hook.Add(“Initialize”,“init_tbl”,function()
if !sql.TableExists(“test_tbl”) then
sql.Query(“CREATE TABLE test_tbl ( time int, text text )”)
end
end)
end
[/lua]

This should help you out.

I see this, and it’s doesn’t help me

Try reading through the tutorial.
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexb23a.html

it’s not gamemode, it’s plugin for Evolve

The code worked fine for me.

[img_thumb]http://puu.sh/VCuY[/img_thumb]

Are you sure you aren’t just confused about the fact there are 0 rows?

The colums seem to work fine.

I never knew text was a valid data format in sqlite. I’ve been using varchar(255) the whole time lol.

Hm, when I call a query to this table, it’s return false. Lol, text is valid data format.

Post the code?

What query are you calling?
If you do anything except sql.TableExists(test_tbl) it will return nil because there are 0 rows.

[lua]
local PLUGIN = {}
PLUGIN.Title = “Notices”
PLUGIN.ChatCommand = “notices_menu”
PLUGIN.Author = “qiwi”
PLUGIN.Privileges = { “Notices” }

if SERVER then
concommand.Add(“push_data”, function(p,c,a)
if ( p:EV_HasPrivilege( “Notices” ) ) then
sql.Query(“INSERT INTO ev_notices (‘time’,‘text’) VALUES (’”…a[1]…"’,’"…a[2]…"’)")
end
end)

hook.Add("Initialize","init_tbl",function()
	sql.Query("CREATE TABLE IF NOT EXISTS ev_notices ( time int, text text )")
	sql.Query("INSERT INTO ev_notices ('time','text') VALUES ('10','lol')")
end)

end

if CLIENT then

usermessage.Hook("notices_menu",function()
	local df = vgui.Create("DFrame")
	df:SetPos(ScrW()/4,ScrH()/4)
	df:SetSize(ScrW()/2,ScrH()/2)
	df:SetTitle("Notices edition menu")
	df:SetDraggable(false)
	df:MakePopup()
	
	local dlv = vgui.Create("DListView",df)
	dlv:SetPos(2,df:GetTall()/23)
	dlv:SetSize(df:GetWide()-4,df:GetTall()*0.85)
	dlv:SetMultiSelect(false)
	dlv:AddColumn("Time")
	dlv:AddColumn("Text")
	if sql.Query("SELECT time, text FROM ev_notices") then
		for _,v in pairs(sql.Query("SELECT time, text FROM ev_notices")) do
			dlv:AddLine(v.time,v.text)
		end
	end
	
	local dtetime = vgui.Create("DTextEntry",df)
	dtetime:SetPos(2,df:GetTall()/23+df:GetTall()*0.86)
	dtetime:SetWide(df:GetWide()/2-4)
	dtetime:SetEnterAllowed(false)
	dtetime:SetValue("Enter time here")
	
	local dtetext = vgui.Create("DTextEntry",df)
	dtetext:SetPos(df:GetWide()/2+2,df:GetTall()/23+df:GetTall()*0.86)
	dtetext:SetWide(df:GetWide()/2-4)
	dtetext:SetEnterAllowed(false)
	dtetext:SetValue("Enter text here")
	
	local acb = vgui.Create("DButton",df)
	acb:SetPos(2,df:GetTall()/23+df:GetTall()*0.87+dtetime:GetTall())
	acb:SetText("Accept")
	acb:SetSize(df:GetWide()-4,df:GetTall()-(df:GetTall()/23+df:GetTall()*0.87+dtetime:GetTall())-2)
	
	acb.DoClick = function()
	local time = tonumber(dtetime:GetValue())
	local text = dtetext:GetValue()
	
	if time~= nil and text~="" then
		RunConsoleCommand("push_data",time,text)
		evolve:Notify(evolve.colors.blue,"Success")
	else evolve:Notify(evolve.colors.red,"Values is incorrect") end
	end
	
end)

end

function PLUGIN:Call( ply, args )

if ( ply:EV_HasPrivilege( "Notices" ) ) then
	umsg.Start("notices_menu",ply)
	umsg.End()
end

end

evolve:RegisterPlugin( PLUGIN )
[/lua]

You can’t query the server database from the client.

So, I should use usermessages?

-snip waste of time-