Bonjour,

Je rencontre un pb (de syntaxe semble t-il) à la création d'une table en mariaDB (pas de pb à la création de la database).
Voici mon code:

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
39
40
41
42
43
44
45
 
database = """CREATE DATABASE IF NOT EXISTS db_solardata;"""
 
t_Solar_Data = """
        CREATE TABLE IF NOT EXISTS t_Solar_Data (
        id_solar_data INT NOT NULL AUTO_INCREMENT,
        updated DATETIME NOT NUL,
        solarflux SMALLINT DEFAULT NUL,
        aindex SMALLINT DEFAULT NUL,
        kindex SMALLINT DEFAULT NUL,
        kindexnt VARCHAR DEFAULT NUL,
        xray VARCHAR DEFAULT NUL,
        sunspots SMALLINT DEFAULT NUL,
        heliumline FLOAT DEFAULT NUL,
        protonflux SMALLINT DEFAULT NUL,
        electonflux SMALLINT DEFAULT NUL,
        aurora SMALLINT DEFAULT NUL,
        normalization FLOAT DEFAULT NUL,
        latdegree FLOAT DEFAULT NUL,
        solarwind FLOAT DEFAULT NUL,
        magneticfield FLOAT DEFAULT NUL,
        geomagfield VARCHAR DEFAULT NUL,
        signalnoise VARCHAR DEFAULT NUL,
        fof2 FLOAT DEFAULT NUL,
        muffactor FLOAT DEFAULT NUL,
        muf FLOAT DEFAULT NUL,
        PRIMARY KEY(id_solar_data) ); """
 
try:
    conn =  mysql.connector.connect(host="127.0.0.1",
                                   user="root", password="raspberry")
    cursor = conn.cursor()
    cursor.execute(database)
    cursor.execute("""use db_solardata;""")
    cursor.execute(t_Solar_Data)
    cursor.execute(t_calculatedconditions)
    cursor.execute(t_calculatedvhfconditions)
except mysql.connector.errors.InterfaceError as e:
    print("Error %d: %s" % (e.args[0], e.args[1]))
    sys.exit(1)
finally:
    # On ferme la connexion
    if conn:
        conn.close()
        print('The database and the tables have been correctly created.')
L'erreur est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NUL,
        solarflux SMALLINT DEFAULT NUL,
        aindex SMALLINT DEFAULT NUL,
        kindex S...' at line 3
Mais je ne parviens à m'en sortir.