SQLite Problem

Just starting out? Need help? Post your questions and find answers here.
davidKain
New User
New User
Posts: 3
Joined: Tue Mar 12, 2024 10:40 pm
Location: NJ, USA

SQLite Problem

Post by davidKain »

Greetings!

Long time VBA / VB6 coder but am new to PureBasic.

I am taking a look at the "Databases" tutorial and even though I normally use MySQL and not SQLite, I figured to try to follow the steps and get a hang of things before migrating over to MySQL.

I'm trying to use the code provided in the tutorial to create a new database. I copy and pasted the Create SQL directly from DB Browser so I'm confident that my syntax is not the issue here.

Code: Select all

CREATE TABLE "servers" (
	"serverid"	INTEGER,
	"srvmachinename"	TEXT,
	"srvOS"	TEXT,
	"srvIP4"	TEXT,
	"adminuser"	TEXT,
	"adminpass"	TEXT,
	"status"	INTEGER NOT NULL DEFAULT 0,
	PRIMARY KEY("serverid")
)
When I paste it into Pure Basic, the first error I get is: 'SERVERS' IS NOT A VALID OPERATOR

Ok so the whole single quote double quote thing is going to take some getting used to.

But when I replace the CheckDatabaseUpdate line with this:

Code: Select all

CheckDatabaseUpdate(0, "CREATE TABLE 'servers' ('serverid' INTEGER, 'srvmachinename' TEXT, 'srvOS' TEXT, 'srvIP4' TEXT, 'adminuser' TEXT, 'adminpass'	TEXT, 'status' INTEGER Not NULL Default 0, PRIMARY KEY('serverid'))"
I get the error: SYNTAX ERROR

Any help would be appreciated!
If at first your code doesn't succeed, slam your keyboard down, storm out of the room, curse like a mother effer, and then pick yourself up and debug again.
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: SQLite Problem

Post by normeus »

The last double quote is in the wrong place:

Code: Select all

CheckDatabaseUpdate(0, "CREATE TABLE 'servers' ('serverid' INTEGER, 'srvmachinename' TEXT, 'srvOS' TEXT, 'srvIP4' TEXT, 'adminuser' TEXT, 'adminpass'	TEXT, 'status' INTEGER Not NULL Default 0, PRIMARY KEY('serverid')")

Take a look at blueznl's great tutorial for PureBasic, he has a lot of examples:

https://www.ninelizards.com/purebasic/index.htm

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
davidKain
New User
New User
Posts: 3
Joined: Tue Mar 12, 2024 10:40 pm
Location: NJ, USA

Re: SQLite Problem

Post by davidKain »

Thanks, Norm. Honestly, with my amount of experience there was no excuse for that oversight. It was 100% "I'm so great, it must be this new program that is wrong"

After changing it to this, everything works as expected

Code: Select all

CheckDatabaseUpdate(0, "CREATE TABLE 'servers' ('serverid' INTEGER, 'srvmachinename' TEXT, 'srvOS' TEXT, 'srvIP4' TEXT, 'adminuser' TEXT, 'adminpass'	TEXT, 'status' INTEGER Not NULL Default 0, PRIMARY KEY('serverid'))")
If at first your code doesn't succeed, slam your keyboard down, storm out of the room, curse like a mother effer, and then pick yourself up and debug again.
Post Reply