User:Dt192
Jump to navigation
Jump to search
Sandbox List of orphaned pages
**Orphaned Pages** https://wiki.mudlet.org/w/Area_51/Mapping_script https://wiki.mudlet.org/w/Artists_performance_package https://wiki.mudlet.org/w/Bounty_Process https://wiki.mudlet.org/w/Chrome_OS https://wiki.mudlet.org/w/Comparison_of_MUD_clients https://wiki.mudlet.org/w/Connection_Window https://wiki.mudlet.org/w/Dependency_Versions https://wiki.mudlet.org/w/Fonts https://wiki.mudlet.org/w/HowTo:OpenInWindowsCmd https://wiki.mudlet.org/w/Mobile_Plan https://wiki.mudlet.org/w/Mudlet_Packaging_System_Info_Template https://wiki.mudlet.org/w/Mudlet_Sponsorship_Plan https://wiki.mudlet.org/w/ProfileBackup https://wiki.mudlet.org/w/Tutorials https://wiki.mudlet.org/w/Updating_PPA https://wiki.mudlet.org/w/VyzorDocumentation https://wiki.mudlet.org/w/VyzorWalkthrough **Links from the main website** https://wiki.mudlet.org/w/Known_Issues **Can't be deleted** https://wiki.mudlet.org/w/Manual:Lua_Functions/Test **To Delete** ...
So i don't forget again. This is how you sent raw sql to the db and fetch the result
mydb = db:create("mydb",
{
mySheet = {
name = "", id = 0, city = "",
_index = { "name" },
_unique = { "id" },
_violations = "FAIL"
}
})
myData = {
{name="Ixokai", city="Magnagora", id=1},
{name="Vadi", city="New Celest", id=2},
{name="Heiko", city="Hallifax", id=3},
{name="Keneanung", city="Hashan", id=4},
{name="Carmain", city="Mhaldor", id=5},
{name="Ixokai", city="Hallifax", id=6},
}
db:add(mydb.mySheet, unpack(myData))
local conn = db.__conn.mydb;
---------------------------------------------------------------------------------------
res = conn:execute("SELECT last_insert_rowid()")
display(res:fetch())
results:close()
----------------------------------------------------------------------------------------
results = conn:execute([[SELECT city,name FROM mySheet WHERE city = 'Hallifax']])
local city,name = results:fetch()
while city do
print(city,name)
city,name = results:fetch()
end
results:close()
----------------------------------------------------------------------------------------
results = conn:execute[[
SELECT * FROM mySheet WHERE name = 'Ixokai'
]]
local res = results:fetch({}, "a")
while res do
print(res.id, res.city, res.name)
res = results:fetch(res, "a")
end
results:close()
----------------------------------------------------------------------------------------
function rows(connection, sql_statement)
local cursor = assert (connection:execute (sql_statement))
return function()
return cursor:fetch()
end
end
local query = [[select id,city,name from mySheet WHERE id > 1 AND id < 5]]
for id,city,name in rows(conn, query) do
print (name, city, id)
end