Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

sqlite query through Python returns strange variable name

I'm using the following Python code to query a SQLite output file produced by EnergyPlus:

import sqlite3
import os

sqlite_file = './test_sql_h.sql'

table_name = 'ReportDataDictionary'
id_column = 'ReportDataDictionaryIndex'
column_a = 'Name'
column_b = 'KeyValue'

# connect to the database file
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()


# identify all unique variable names
c.execute(
        ' SELECT DISTINCT ({col}) FROM {tn} '.\
        format(tn=table_name, col=column_a)
        )
all_names_unique = c.fetchall()
for i in range(0, len(all_names_unique)):
    print(all_names_unique[i])

# commit changes and queries, and close the connection
conn.commit()
conn.close()

However, each variable name is enclosed in a pair of single quotation marks proceeded by the letter "u" as shown below.

(u'Zone Lights Electric Energy',)
(u'Zone Electric Equipment Electric Energy',)
(u'Zone Ideal Loads Supply Air Total Heating Energy',)
(u'Zone Ideal Loads Supply Air Total Cooling Energy',)

May I ask why the output is not the pure name of the variable?

Thanks.

sqlite query through Python returns strange variable name

I'm using the following Python code to query a SQLite output file produced by EnergyPlus:

import sqlite3
import os

sqlite_file = './test_sql_h.sql'

table_name = 'ReportDataDictionary'
id_column = 'ReportDataDictionaryIndex'
column_a = 'Name'
column_b = 'KeyValue'

# connect to the database file
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()


# identify all unique variable names
c.execute(
        ' SELECT DISTINCT ({col}) FROM {tn} '.\
        format(tn=table_name, col=column_a)
        )
all_names_unique = c.fetchall()
for i in range(0, len(all_names_unique)):
    print(all_names_unique[i])

# commit changes and queries, and close the connection
conn.commit()
conn.close()

However, each variable name is enclosed in a pair of single quotation marks proceeded by the letter "u" as shown below.

(u'Zone Lights Electric Energy',)
(u'Zone Electric Equipment Electric Energy',)
(u'Zone Ideal Loads Supply Air Total Heating Energy',)
(u'Zone Ideal Loads Supply Air Total Cooling Energy',)

May I ask why the output is not the pure name of the variable?

Thanks.

sqlite SQLite query through Python returns strange variable name

I'm using the following Python code to query a SQLite output file produced by EnergyPlus:

import sqlite3
import os

sqlite_file = './test_sql_h.sql'

table_name = 'ReportDataDictionary'
id_column = 'ReportDataDictionaryIndex'
column_a = 'Name'
column_b = 'KeyValue'

# connect to the database file
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()

 # identify all unique variable names
c.execute(
        ' SELECT DISTINCT ({col}) FROM {tn} '.\
        format(tn=table_name, col=column_a)
        )
all_names_unique = c.fetchall()
for i in range(0, len(all_names_unique)):
    print(all_names_unique[i])

# commit changes and queries, and close the connection
conn.commit()
conn.close()

However, each variable name is enclosed in a pair of single quotation marks proceeded by the letter "u" as shown below.

(u'Zone Lights Electric Energy',)
(u'Zone Electric Equipment Electric Energy',)
(u'Zone Ideal Loads Supply Air Total Heating Energy',)
(u'Zone Ideal Loads Supply Air Total Cooling Energy',)

May I ask why the output is not the pure name of the variable?

Thanks. Thanks.

SQLite query through Python returns strange variable name

I'm using the following Python code to query a SQLite output file produced by EnergyPlus:

import sqlite3
import os

sqlite_file = './test_sql_h.sql'

table_name = 'ReportDataDictionary'
id_column = 'ReportDataDictionaryIndex'
column_a = 'Name'
column_b = 'KeyValue'

# connect to the database file
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()

# identify all unique variable names
c.execute(
        ' SELECT DISTINCT ({col}) FROM {tn} '.\
        format(tn=table_name, col=column_a)
        )
all_names_unique = c.fetchall()
for i in range(0, len(all_names_unique)):
    print(all_names_unique[i])

# commit changes and queries, and close the connection
conn.commit()
conn.close()

However, each variable name is enclosed in a pair of single quotation marks proceeded by the letter "u" as shown below.

(u'Zone Lights Electric Energy',)
(u'Zone Electric Equipment Electric Energy',)
(u'Zone Ideal Loads Supply Air Total Heating Energy',)
(u'Zone Ideal Loads Supply Air Total Cooling Energy',)

May I ask why the output is not the pure name of the variable?

Thanks.

SQLite query through Python returns strange variable name

I'm using the following Python code to query a SQLite output file produced by EnergyPlus:

import sqlite3
import os

sqlite_file = './test_sql_h.sql'

table_name = 'ReportDataDictionary'
id_column = 'ReportDataDictionaryIndex'
column_a = 'Name'
column_b = 'KeyValue'

# connect to the database file
conn = sqlite3.connect(sqlite_file)
c = conn.cursor()

# identify all unique variable names
c.execute(
        ' SELECT DISTINCT ({col}) FROM {tn} '.\
        format(tn=table_name, col=column_a)
        )
all_names_unique = c.fetchall()
for i in range(0, len(all_names_unique)):
    print(all_names_unique[i])

# commit changes and queries, and close the connection
conn.commit()
conn.close()

However, each variable name is enclosed in a pair of single quotation marks proceeded by the letter "u" as shown below.

(u'Zone Lights Electric Energy',)
(u'Zone Electric Equipment Electric Energy',)
(u'Zone Ideal Loads Supply Air Total Heating Energy',)
(u'Zone Ideal Loads Supply Air Total Cooling Energy',)

May I ask why the output is not the pure name of the variable?

Thanks.