View previous topic :: View next topic |
Author |
Message |
Asparius
Joined: 18 Sep 2007 Posts: 52
|
Posted: Fri Jul 03, 2009 13:15 Post subject: SQLite and AUTOINCREMENT |
|
|
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 |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Fri Jul 03, 2009 14:22 Post subject: |
|
|
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 |
|
|
Asparius
Joined: 18 Sep 2007 Posts: 52
|
Posted: Fri Jul 03, 2009 22:41 Post subject: |
|
|
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 |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sat Jul 04, 2009 0:26 Post subject: |
|
|
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 |
|
|
Gryphyn
Joined: 20 Jan 2005 Posts: 431
|
Posted: Sat Jul 04, 2009 0:40 Post subject: |
|
|
FAQ #1 |
|
Back to top |
|
|
doxic
Joined: 07 Oct 2008 Posts: 13
|
Posted: Tue Jul 14, 2009 22:02 Post subject: |
|
|
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 |
|
|
Asparius
Joined: 18 Sep 2007 Posts: 52
|
Posted: Thu Jul 16, 2009 14:10 Post subject: |
|
|
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 |
|
|
|