Új hozzászólás Aktív témák

  • Siriusb

    veterán

    válasz sztanozs #1858 üzenetére

    Persze, hogy nincs benne datum nevű oszlop, mert az csak alias, a valódi oszlop dateofrecording névre hallgat..

    A problémám lényege az volt, hogy az alias csak "current_date" név lehet (hiába találtam ki a "datum" fantázianevet), ugye ez hivatkozik a valódi, a táblában megtalálható "dateofrecording" nevű oszlopra a konverter szintaktikájában:
    datum AS "dateofrecording [date]"
    alias AS "oszlopnév [adattípus]"

    azaz a konverter megkapja a mező nevét a táblából "dateofrecording", valamint hogy milyen típusra konvertálja a tartalmát a lekérdezéskor: [date], de a hivatkozási név nem lehet "datum" vagy bármi más, csak és kizárólag a "current_date" név megadásával hajlandó működni a konverter.
    Ez nem olyan nagy baj, csak lenne leírva. :D
    Mert ebből nem derült ki számomra:

    sqlite3.PARSE_COLNAMES
    This constant is meant to be used with the detect_types parameter of the connect() function.
    Setting this makes the SQLite interface parse the column name for each column it returns. It will look for a string formed [mytype] in there, and then decide that ‘mytype’ is the type of the column. It will try to find an entry of ‘mytype’ in the converters dictionary and then use the converter function found there to return the value. The column name found in Cursor.description is only the first word of the column name, i. e. if you use something like 'as "x [datetime]"' in your SQL, then we will parse out everything until the first blank for the column name: the column name would simply be “x”.

    https://docs.python.org/3/library/sqlite3.html

Új hozzászólás Aktív témák