WhoAmI Posted February 26, 2014 Posted February 26, 2014 Hi guys. I just want to now how I can create a table includes column with auto increment? executeSQLQuery("CREATE TABLE IF NOT EXISTS name (id NOT NULL AUTO_INCREMENT, other_stuff TEXT)") And it outputs error. Anyone knows?
Wei Posted February 26, 2014 Posted February 26, 2014 executeSQLQuery("CREATE TABLE IF NOT EXISTS name (id INT NOT NULL AUTO_INCREMENT, other_stuff TEXT)") This should work, you didn't specify the id type
cheez3d Posted February 26, 2014 Posted February 26, 2014 executeSQLQuery("CREATE TABLE IF NOT EXISTS `dbName` (ID INT(5) NOT NULL AUTO_INCREMENT, Name TEXT NOT NULL), PRIMARY KEY (ID)")
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 Both same error. http://snag.gy/wQyia.jpg
Wei Posted February 26, 2014 Posted February 26, 2014 Both same error.http://snag.gy/wQyia.jpg Try dropping table
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 There's nothing to drop. Couse of error, tables didn't create.
Wei Posted February 26, 2014 Posted February 26, 2014 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
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 Nah. Same error. When im writing NOT_NUL, instead of NUT NULL there is no error, but when im getting the data, I can't get id cloumn's values.
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 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"?
Wei Posted February 26, 2014 Posted February 26, 2014 @EDIT: When i'm deleting "NOT NULL", everything is okey. Does MTA not support "NOT NULL"? Gues not then, I did it with mysql connection and everything worked fine, so it's working now ?
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 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.
WhoAmI Posted February 26, 2014 Author Posted February 26, 2014 Well, I did this, using https://addons.mozilla.org/pl/firefox/a ... e-manager/ and files .sqlite.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now