Bonsoir, je suis en train d'écrire un programme basique qui remplit une base de données gadfly à partir d'une liste. Il plante lamentablement, et ne voyant pas l'erreur, j'en viens à me demander si gadfly gère bien les listes.
Mon programme:
Et le magnifique message d'erreur qui en ressort:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 import gadfly baseMusic=gadfly.gadfly() baseMusic.startup("mymusic", "/home/divayht/python/database/gadfly/music/") cur=baseMusic.cursor() liste_comp=[('Mozart', 1756, 1791), ('Beethoven', 1770, 1827), ('Handel', 1685, 1759), ('Schubert', 1797, 1828), ('Vivaldi', 1678, 1741), ('Monteverdi', 1567, 1643), ('Chopin', 1810, 1849), ('Bach', 1685, 1750)] liste_oeuvres=[('Vivaldi', 'Les quatre saisons', 20, 'T. Pinnock'), ('Mozart', 'Concerto piano N 12', 25, 'M. Perahia'), ('Brahms', 'Concerto violon N 2', 40, 'A. Grumiaux'), ('Beethoven', 'Sonate Au clair de la lune', 14, 'W. Kempf'), ('Beethoven', 'Sonate Pathetique', 17, 'W. Kempf'), ('Schubert', 'Quintette La truite', 39, 'SE of London'), ('Haydn', 'La creation', 109, 'H. Von Karajan'), ('Chopin', 'Concerto piano N 1', 42, 'M.J. Pires'), ('Bach', 'Toccata and fugue', 9, 'P. Burmester'), ('Beethoven', 'Concerto piano N 4', 33, 'M. Pollini'), ('Mozart', 'Symphonie N 40', 29, 'F. Bruggen'), ('Mozart', 'Concerto piano N 22', 35, 'S. Richter'), ('Beethoven', 'Concerto piano N 3', 37, 'S. Richter')] cur.execute("create table compositeurs (comp varchar, a_naiss integer, a_mort integer)") for i in liste_comp: cur.execute("insert into compositeurs(comp, a_naiss, a_mort) values (i[0], i[1], i[2])") cur.execute("create table oeuvres (comp varchar, titre varchar, duree integer, interpr varchar)") for i in liste_oeuvres: cur.execute("insert into oeuvres(comp, titre, duree, interpr) values (i[0], i[1], i[2], i[3])") baseMusic.commit()
Merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 /usr/lib/python2.6/dist-packages/gadfly/store.py:11: DeprecationWarning: the md5 module is deprecated; use hashlib instead import sys, os, md5, types, marshal Traceback (most recent call last): File "music_table.py", line 35, in <module> cur.execute("insert into compositeurs(comp, a_naiss, a_mort) values (i[0], i[1], i[2])") File "/usr/lib/python2.6/dist-packages/gadfly/database.py", line 339, in execute cs = self.commands = self.connection.sql.DoParse1(statement, context) File "/usr/lib/python2.6/dist-packages/gadfly/kjParser.py", line 1161, in DoParse1 return self.DoParse(String, Context, DoReductions)[0] File "/usr/lib/python2.6/dist-packages/gadfly/kjParser.py", line 1153, in DoParse ParseResult = ParseOb.GO() File "/usr/lib/python2.6/dist-packages/gadfly/kjParser.py", line 827, in GO self.DoOneReduction() File "/usr/lib/python2.6/dist-packages/gadfly/kjParser.py", line 760, in DoOneReduction self.ParseError(current,tokenVal, "nomatch1") File "/usr/lib/python2.6/dist-packages/gadfly/kjParser.py", line 811, in ParseError raise SyntaxError, 'unexpected token sequence.' + data SyntaxError: unexpected token sequence.near :: '_mort) values ('*'i[0], i[1], i[2' ******************************* current state = 186 expects: 'numeric_literal', 'character_string_literal', '?', '+', '-', ('nomatch1',) current token = ((-8, 'user_defined_name'), 'I')
Partager