Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Questions about sqlite schema
Questions about sqlite schema [message #25816] Sat, 13 March 2010 20:07 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I am trying to replicate an application written in PHP+MySql with Upp+Sqlite. I jave two questions.

1) With the following table I have problem at runtime
TABLE_(DBELO) 
  STRING   (NOME, 35)
  INT_     (ELO)
  STRING_  (CAT, 4)
  INT_     (K)
  STRING   (SIGLAPROV, 2)
  DATE_    (DATA)
  INT_     (IDFIDE)
  INT_     (IDFSI)  PRIMARY_KEY
  STRING_  (SEX, 1)
END_TABLE

ERROR Cannot add a PRIMARY KEY column(0): Preparing: alter table DBELO add IDFSI integer primary key

The problem disappear if I move the field
INT_ (IDFSI) PRIMARY_KEY
at the top of declaration. Is it normal?

2) I have used the Firefox plugin SQLite Manager to import the data (csv file) from MySql into Sqlite database. Now I am going to write the Upp code to perform some operation. The question is: Do I need a schema file in order to work with a sqlite database? Can I update, select, delete data without a *.sch file?
I know that it can simplify the tasks but I do not care.

Thank you,
Luigi

[Updated on: Sat, 13 March 2010 20:08]

Report message to a moderator

Re: Questions about sqlite schema [message #26038 is a reply to message #25816] Fri, 26 March 2010 18:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Sat, 13 March 2010 14:07

Hello,

I am trying to replicate an application written in PHP+MySql with Upp+Sqlite. I jave two questions.

1) With the following table I have problem at runtime
TABLE_(DBELO) 
  STRING   (NOME, 35)
  INT_     (ELO)
  STRING_  (CAT, 4)
  INT_     (K)
  STRING   (SIGLAPROV, 2)
  DATE_    (DATA)
  INT_     (IDFIDE)
  INT_     (IDFSI)  PRIMARY_KEY
  STRING_  (SEX, 1)
END_TABLE

ERROR Cannot add a PRIMARY KEY column(0): Preparing: alter table DBELO add IDFSI integer primary key

The problem disappear if I move the field
INT_ (IDFSI) PRIMARY_KEY
at the top of declaration. Is it normal?



I am afraid yes. Why do not you want it to be first? Smile

Quote:


2) I have used the Firefox plugin SQLite Manager to import the data (csv file) from MySql into Sqlite database. Now I am going to write the Upp code to perform some operation. The question is: Do I need a schema file in order to work with a sqlite database?



No, you do not.

Quote:


Can I update, select, delete data without a *.sch file?
I know that it can simplify the tasks but I do not care.



Yes. You might need to define some SqlIds if you want to use SqlExp. And you cannot use S_* structures to fetch whole records.

But other than that, of course, you do no need .sch. .sch is just extension/option.
Re: Questions about sqlite schema [message #26054 is a reply to message #26038] Fri, 26 March 2010 23:22 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
luzr wrote on Fri, 26 March 2010 18:20

forlano wrote on Sat, 13 March 2010 14:07

Hello,

I am trying to replicate an application written in PHP+MySql with Upp+Sqlite. I jave two questions.

1) With the following table I have problem at runtime
TABLE_(DBELO) 
  STRING   (NOME, 35)
  INT_     (ELO)
  STRING_  (CAT, 4)
  INT_     (K)
  STRING   (SIGLAPROV, 2)
  DATE_    (DATA)
  INT_     (IDFIDE)
  INT_     (IDFSI)  PRIMARY_KEY
  STRING_  (SEX, 1)
END_TABLE

ERROR Cannot add a PRIMARY KEY column(0): Preparing: alter table DBELO add IDFSI integer primary key

The problem disappear if I move the field
INT_ (IDFSI) PRIMARY_KEY
at the top of declaration. Is it normal?



I am afraid yes. Why do not you want it to be first? Smile



Hello,

because using sqlitebrowser I can import without problem a cvs file exported by MySql with phpmyadmin. If I mix the column order a mismmatch occur and I need to prepare my own import routine.

Luigi
Re: Questions about sqlite schema [message #26122 is a reply to message #26054] Fri, 02 April 2010 10:48 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Hm, I would just remove PRIMARY_KEY... and perhaps replace it with INDEX.

Mirek
Previous Topic: sqlite busy/lock timeout patch
Next Topic: Any way to generate sch from database?
Goto Forum:
  


Current Time: Fri Mar 29 01:49:05 CET 2024

Total time taken to generate the page: 0.01703 seconds