Jump to content

SQLite


WhoAmI

Recommended Posts

executeSQLQuery("CREATE TABLE Persons(ID int NOT NULL AUTO_INCREMENT,LastName varchar(255) NOT NULL,FirstName varchar(255),Address varchar(255),City varchar(255),PRIMARY KEY (ID))") 
  

Try that that was directly copied from some mysql website, If it doesn't work it's maybe not supported by MTA executeSQLQuery

Link to comment
handler = dbConnect("sqlite", "file.db") 
dbQuery(handler, "CREATE TABLE IF NOT EXISTS Persons(ID int NOT NULL AUTO_INCREMENT,LastName varchar(255) NOT NULL,FirstName varchar(255),Address varchar(255),City varchar(255))") 

Well, I did sth like this, but when im starting resource, file.db is clear.

@EDIT: When i'm deleting "NOT NULL", everything is okey. Does MTA not support "NOT NULL"?

Link to comment

Yea, I did same thing in MySQL and it works. Was disappointed why it isn't working here.

It isn't working, when im deleting this, the column "ID" returns just nil.

There is my code:

handler = dbConnect("sqlite", "file.db") 
dbQuery(handler, "CREATE TABLE Persons(ID INT AUTO_INCREMENT NOT NULL, LastName varchar(255))") 
  
addCommandHandler("add", 
    function () 
        dbQuery(handler, "INSERT INTO Persons(LastName) VALUES (?)", "Jacob") 
    end 
) 
  
addCommandHandler("check", 
    function () 
        local data = dbQuery(handler, "SELECT * FROM Persons") 
        if (data) then 
            local result = dbPoll(data, -1) 
            for k,v in ipairs(result) do outputChatBox(v["id"]..v["LastName"]) end 
        end 
    end 
) 

And the v["id"] gives nil.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...