Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ The special filename ":memory:" opens an in-memory database.

The special filename ":memory:" opens an in-memory database.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Narci   (32 posts)  Bio
Date Sat 02 Aug 2014 09:16 AM (UTC)

Amended on Sat 02 Aug 2014 09:45 AM (UTC) by Narci

Message
This the code:

require "tprint"

DatabaseOpen ("db", GetInfo (66) .. ":memory:", 6)

rc = DatabaseExec ("db", [[
DROP TABLE IF EXISTS weapons;
CREATE TABLE weapons(
        weapon_id INTEGER NOT NULL PRIMARY KEY autoincrement,
        name  TEXT NOT NULL,
        damage INT default 10,
        weight REAL
      );
      ]])
      

-- put some data into the database
DatabaseExec ("db", 
  [[
  INSERT INTO weapons (name, damage) VALUES ('sword', 42);
  INSERT INTO weapons (name, damage) VALUES ('mace', 55);
  INSERT INTO weapons (name, damage) VALUES ('staff', 35);
  ]])

-- prepare a query
DatabasePrepare ("db", "SELECT * from weapons ORDER BY name")

-- find the column names
names = DatabaseColumnNames ("db")
tprint (names)

-- execute to get the first row
rc = DatabaseStep ("db")  -- read first row

-- now loop, displaying each row, and getting the next one
while rc == 100 do
  
  print ("")
  values = DatabaseColumnValues ("db")
  tprint (values)

  rc = DatabaseStep ("db")  -- read next row

end -- while loop

-- finished with the statement
DatabaseFinalize ("db")

DatabaseClose ("db")  -- close it



but it no work...
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 02 Aug 2014 09:39 AM (UTC)
Message
Quote:

DatabaseOpen ("db", GetInfo (66) .. ":memory:", 6)


In my case GetInfo (66) is:


C:\Program Files\MUSHclient\


So the filename:


GetInfo (66) .. ":memory:"


would be:


C:\Program Files\MUSHclient\:memory:


Would it not?

That is not exactly the same as ":memory:" is it?

Your code works if you omit the "GetInfo (66)".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Narci   (32 posts)  Bio
Date Reply #2 on Sat 02 Aug 2014 09:48 AM (UTC)
Message
Now,I know.
thank you!
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,531 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.