Receive a welcome greeting from me.
I'm experimenting with QT (QT Creator) and database (Postgres 8.3) with the QxOrm ORM, but I have some doubts.
I'm studying the documentation QxOrm on the page:
http://www.qxorm.com/qxorm_en/home.html
I made some tests using the quick sample:
http://www.qxorm.com/qxorm_en/quick_sample.html
However the example shown for a database (SQLite version 3) and I'm doing tests for Postgres (QPSQL) which compiled and work to connect to the postgres database, making insert, delete, update, etc, all this works.
The connection with the postgres driver I did:
- Code: Select all
// Postgres
qx: QxSqlDatabase:: getSingleton () -> setDriverName ("QPSQL");
The trouble arises when I try to insert a table in the database using the QxOrm with the following instructions:
- Code: Select all
// Create Table 'drug' within the database
QSqlError daoError = qx:: dao: <drug> create_table ();
This statement produces the following SQL in debug:
CREATE TABLE drug (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT, desc TEXT)
This sql statement is a trouble for postgres tables because apparently "type sequence" in postgres not understand the instruction "AUTOINCREMENT". The postgres throws the following error:
ERROR: syntax error at or near "AUTOINCREMENT"
LINE 1: ... REAT drug TABLE (id INTEGER NOT NULL PRIMARY KEY AUTOINCREM ...
^
********** ********** Error
ERROR: syntax error at or near "AUTOINCREMENT"
SQL state: 42601
Character: 52
I'm not sure I should tell the ORM I want to generate scripts for Postgres database instead of SQLite. I thought that this was done automatically as you enter the driver QPSQL.
I wonder if anyone has had this problem and give me a light.
Thank you very much.
Buenas Tardes:
Reciban un grato saludo de mi parte.
Estoy haciendo pruebas con QT (QT Creator) y base de datos (Postgres 8.3) junto con el ORM QxOrm, pero me han surgido algunas dudas.
Estoy estudiando la documentación de QxOrm en la pagina:
http://www.qxorm.com/qxorm_en/home.html
He realizado algunas pruebas a partir del ejemplo “rápido” de la dirección:
http://www.qxorm.com/qxorm_en/quick_sample.html
Sin embargo el ejemplo se muestra para una base de datos en (SQLite version 3) y yo estoy realizando las pruebas para Postgres (QPSQL) el cual ya compile y funciona para conectarse a la base de datos postgres, hacer inserciones, eliminaciones, modificaciones, etc, todo esto me funciona.
La conexión con el driver postgres la hice así:
- Code: Select all
// Postgres
qx::QxSqlDatabase::getSingleton()->setDriverName("QPSQL");
El problema me surge al intentar insertar una tabla en la base de datos empleando el QxOrm con las instrucciones siguientes:
// Crea Tabla 'drug' dentro de la base de datos
QSqlError daoError = qx::dao::create_table<drug>();
Esta instrucción genera el SQL siguiente según el debug:
- Code: Select all
CREATE TABLE drug (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT, desc TEXT)
Este sentencia sql es un problema para postgres porque al pareces las tablas “tipo secuencia” en postgres no comprenden la instrucción “AUTOINCREMENT” se manejan de manera diferente. El postgres arroja el siguiente error:
ERROR: syntax error at or near "AUTOINCREMENT"
LINEA 1: ...REATE TABLE drug (id INTEGER NOT NULL PRIMARY KEY AUTOINCREM...
^
********** Error **********
ERROR: syntax error at or near "AUTOINCREMENT"
SQL state: 42601
Character: 52
No estoy segura si me esta faltando indicarle al ORM que deseo general los scripts de bases de datos para una Base de Datos Postgres y no una base de datos SQLite. Pense que esto se hacia automáticamente al indicar el driver QPSQL.
Quisiera saber si alguien ha tenido un problema similar al mío que me pueda aclarar esta situación o mostrar alguna luz.
Muchas Gracias.