Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Selecting Database for Queries (https://forums.graalonline.com/forums/showthread.php?t=134269047)

sssssssssss 01-28-2014 12:55 AM

Selecting Database for Queries
 
How do you select a database for queries with SQLite? I'm used to PHP and connecting with the declared db name, user, and pass. :/

I've searched and searched on here but can't seem to find it. I've tried ("USE dbname") and ("USE DATABASE dbname") as a query in with my select query and before instead, no go just get this error:

NPC Code:
SQL Error: near "USE": syntax error
Query: USE DATABASE players



If i just use the default db with the table, my query works fine so I know it's not that.

cbk1994 01-28-2014 01:16 AM

Use requestsql2:

Quote:

Originally Posted by Stefan (Post 1557272)
Support for multiple sqlite databases has been added for private and hosted playerworlds. If it's working fine then we can copy it to the other servers. You need to restart the server to enable it.

Server option:
database=dbname,dbfile
First parameter: the name of the database which will be used for requestsql2 (so that you can change the associated file name without breaking scripts)
Second parameter: the filename, cannot contain path names and without extension, will be stored in databases/dbfile.db
Note: you can add several custom databases, it will tell you when a database has been closed because you have removed the configuration (can be used to securely close a database).

Script usage:
requestsql2(dbname, query, wantresult);

Overwriting the default database configuration:
database=default,main_new

The default database will be used for requestsql(query, wantresult).

The system still supports external mysql connections but they cannot be configured this way (needs my help). This is to prevent that the user name and password are shown in the server options.


sssssssssss 01-28-2014 01:17 AM

Yeah I just realized that. I'm completely stupid. was using requestsql instead...

thank you still.


All times are GMT +2. The time now is 01:54 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.