logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
SQLite and AUTOINCREMENT

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Fri Jul 03, 2009 13:15    Post subject: SQLite and AUTOINCREMENT Reply with quote

Hello again.
I am trying to convert my old system from using MySQL to SQLite. The problem is, I can't use autoincrement in internal sqlite database - when I use it I get something like:

Code:

o Got request: CREATE TABLE players_id (id INTEGER PRIMARY KEY AUTOINCREMENT, login VARCHAR(64), name VARCHAR(64))
! SQL Error: near "AUTOINCREMENT": syntax error


The same query does work on SQLite console (but it is version 3.6.16).

Would be it a good solution to use rowid instead?...
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Fri Jul 03, 2009 14:22    Post subject: Reply with quote

The issue might be due to nwnx_odbc using crazy old libs. You might have some luck with what I posted here, but I'm not sure I've ever updated the sqlite lib.

The real question is, why are you converting from MySQL to SQLite?! MySQL is better in every way I can think of, except arguably speed, but if MySQL and NWN are on the same machine, the difference should be negligible (if it isn't, your code is to blame, not MySQL).
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Fri Jul 03, 2009 22:41    Post subject: Reply with quote

Thanks - I will try it. If it won't work, does using rowid seem like a good idea? From what I did read, it should increase by one for each row (at least until it will hit the ceiling - and thats unlikely to happen).

PS. I am converting my old system for other server that uses SQLite - thats why I am converting it.
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Sat Jul 04, 2009 0:26    Post subject: Reply with quote

Asparius wrote:
PS. I am converting my old system for other server that uses SQLite - thats why I am converting it.

Still doesn't seem like a good reason!

rowid might work, not really sure. If not, you might need your own manually-incremented "id" field.
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Sat Jul 04, 2009 0:40    Post subject: Reply with quote

FAQ #1
Back to top
View user's profile Send private message
doxic



Joined: 07 Oct 2008
Posts: 13

PostPosted: Tue Jul 14, 2009 22:02    Post subject: Reply with quote

Code:
o Got request: CREATE TABLE players_id (id INTEGER PRIMARY KEY AUTOINCREMENT, login VARCHAR(64), name VARCHAR(64))
! SQL Error: near "AUTOINCREMENT": syntax error


In SQLite you need to put the primary key definition to the end.
Should look like this:

Code:
CREATE TABLE players_id (id INTEGER AUTOINCREMENT, login VARCHAR(64), name VARCHAR(64), Primary Key(id))


But "rowid" works also.
Back to top
View user's profile Send private message
Asparius



Joined: 18 Sep 2007
Posts: 52

PostPosted: Thu Jul 16, 2009 14:10    Post subject: Reply with quote

Tkanks for all answers - I managed to talk second server admin into using MySQL, but nevertheless using sqlite can be quite useful when starting temporary server for a few hours..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group