#5 SQL Output always drops the table?


The SQL output always includes the:

CREATE TABLE metricTokens (


CREATE TABLE metricData (


If I read the docs correctly, these should only be
generated if I pass -N as an argument.


  • Reginald B. Charney

    • assigned_to: nobody --> rcharney
    • status: open --> pending-accepted
  • Reginald B. Charney

    Logged In: YES

    In actual fact, PyMetrics is working correctly - but
    something may need to be done to eliminate the confusion wrt
    the -N flag.

    Currently, PyMetrics produces a SQL command file by default.
    The first time the file is created, the header is written -
    regardless of the setting of the -N option. This header
    always includes the DROP Table command. (On some SQL RDBMS
    systems, you can not CREATE an existing table.) On any
    subsequent run without the -N option, data is appended to
    the SQL command file. Thus, at any given time. you can
    recreate the table completely using the generated SQL
    command file.

    As currently implemented, there is no option to allow you to
    INSERT the new data without recreating the table. I will add
    such an option for the next release. However, using this new
    option will create a command file that will not work if the
    data tables do not already exist.

    Lastly, in some future version of PyMetrics, I will query
    the database directly to see if the tables exists and act

  • Robert Brinton

    Robert Brinton - 2005-06-07

    Logged In: YES

    I agree that on some systems (most I have encountered) you
    cannot create an existing table, but the DROP TABLE causes
    all of the current data to be discarded.

    Every time I ran the file it would discard all of the old
    data and then add the new data. I thought the intent of
    using a database was to keep the data from previous runs for

    I have attached a sample SQL file that works to create the
    tables (if they do not exist) with MSDE / SQL Server.
    Unfortunately in the sample, I believe the Primary key is
    reassigned every time the SQL is run.

  • Robert Brinton

    Robert Brinton - 2005-06-07
    • status: pending-accepted --> open-accepted
  • Robert Brinton

    Robert Brinton - 2005-06-07

    Sample SQL file for MSDE / SQLServer (windows file)

  • Reginald B. Charney

    Logged In: YES


    Can I ask you to try this SQL statement on your system:

    CREATE TABLE IF NOT EXISTS table1 (field1 integer);

    If this works, then it will have a profound affect on the
    way the SQL tables are set up and the related PyMetrics options.

    The version of MySQL (mysql Ver 12.22 Distrib 4.0.21) Ithat
    I am using does not yet support INFORMATION_SCHEMA.TABLES,
    nor does it support


    My impression is that CREATE TABLE IF NOT EXISTS xxx ... is
    more standard.

  • Robert Brinton

    Robert Brinton - 2005-06-08

    Logged In: YES

    The SQL command generates an error with MSDE and with MS
    Access (it was much harder to find a place to attempt a
    CREATE TABLE in MS Access).

    The MS Reference page for CREATE TABLE is here:

    I have found most SQL to be common for normal INSERT /
    UPDATE / SELECT commands, but to be very different when it
    comes to administrative commands. (Create/Delete Tables,
    Indexes, Contstraints, relationships...)

    What do you think about developing target system specific
    files to create the tables, and then using generic SQL for
    the updates?

    The 'keep appending' option for the SQL and CSV files makes
    some sense, but once the data from the SQL file is moved
    into the database, you don't want to keep it in the SQL file
    do you?

  • Reginald B. Charney

    • status: open-accepted --> closed-accepted
  • Reginald B. Charney

    Logged In: YES

    In release 0.7.6, there is a -e option that suppresses
    recreation of a new table because it is said to already
    exist. This option results on a SQL command file consisting
    of INSERT statements only.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks