import fdb
ruta = 'ale.fdb'
try:
con = fdb.connect(
dsn = ruta,
user = 'sysdba',
password = '*******',
charset = 'utf-8'
)
print('Conectado !!')
print('**************************************************')
except:
print('Fallo la conexion', ruta)
# ********************************************
cx = con.cursor()
sql2 = '''
CREATE TABLE RUBY (
Id BIGINT NOT NULL PRIMARY KEY,
nombre VARCHAR(60) CHARACTER SET UTF8 NOT NULL,
correo VARCHAR(60) CHARACTER SET UTF8 NOT NULL UNIQUE,
pais VARCHAR(60) CHARACTER SET UTF8 NOT NULL,
contra VARCHAR(60) CHARACTER SET UTF8 NOT NULL
);
CREATE GENERATOR gen_ruby_id;
SET GENERATOR gen_ruby_id TO 0;
CREATE TRIGGER BI_RUBY_ID FOR RUBY
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
if (NEW.id is NULL) THEN NEW.id = GEN_ID(gen_ruby_id, 1);
END
'''
cx.execute(sql2)
con.commit()
con.close()
print('Tabla creada !!!')
input()
Lo pregunto porque me sale error de sintaxis, o sea, que algo no está bien escrito. Este es el error:
Traceback (most recent call last):
File "C:\Users\Beto\Documents\Proyectos python\Ruby\fire.py", line 55, in <module>
cx.execute(sql2)
File "C:\Users\Beto\AppData\Local\Programs\Python\Python35\lib\site-packages\fdb\fbcore.py", line 3573, in execute
self._ps = PreparedStatement(operation, self, True)
File "C:\Users\Beto\AppData\Local\Programs\Python\Python35\lib\site-packages\fdb\fbcore.py", line 2182, in __init__
"Error while preparing SQL statement:")
fdb.fbcore.DatabaseError: ('Error while preparing SQL statement:\n- SQLCODE: -104\n- Dynamic SQL Error\n- SQL error code = -104\n- Token unknown - line 10, column 1\n- CREATE', -104, 335544569)