当前位置: 首页>>代码示例>>Python>>正文


Python sqlite3.PARSE_DECLTYPES属性代码示例

本文整理汇总了Python中sqlite3.PARSE_DECLTYPES属性的典型用法代码示例。如果您正苦于以下问题:Python sqlite3.PARSE_DECLTYPES属性的具体用法?Python sqlite3.PARSE_DECLTYPES怎么用?Python sqlite3.PARSE_DECLTYPES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在sqlite3的用法示例。


在下文中一共展示了sqlite3.PARSE_DECLTYPES属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __open

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def __open(self):
        if not self.createIfNotExists and not os.path.exists(self.fileName):
            return False

        self.connection = sqlite3.connect(self.fileName, detect_types=sqlite3.PARSE_DECLTYPES)
        if(self.connection):
            self.connection.row_factory = sqlite3.Row
            self.connection.text_factory = str

            self.cursor = self.connection.cursor()
            self.cursor.execute("PRAGMA foreign_keys=1")

            self.versionTable = RMVersionTable(self)

            return True
        return False 
开发者ID:sprinkler,项目名称:rainmachine-developer-resources,代码行数:18,代码来源:rmDatabase.py

示例2: CheckConvertTimestampMicrosecondPadding

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def CheckConvertTimestampMicrosecondPadding(self):
        """
        http://bugs.python.org/issue14720

        The microsecond parsing of convert_timestamp() should pad with zeros,
        since the microsecond string "456" actually represents "456000".
        """

        con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES)
        cur = con.cursor()
        cur.execute("CREATE TABLE t (x TIMESTAMP)")

        # Microseconds should be 456000
        cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.456')")

        # Microseconds should be truncated to 123456
        cur.execute("INSERT INTO t (x) VALUES ('2012-04-04 15:06:00.123456789')")

        cur.execute("SELECT * FROM t")
        values = [x[0] for x in cur.fetchall()]

        self.assertEqual(values, [
            datetime.datetime(2012, 4, 4, 15, 6, 0, 456000),
            datetime.datetime(2012, 4, 4, 15, 6, 0, 123456),
        ]) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:27,代码来源:regression.py

示例3: init_db

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def init_db(self):
        """Connect to the database, and create tables if necessary."""
        if not self.enabled:
            self.db = DummyDB()
            return
        
        # use detect_types so that timestamps return datetime objects
        kwargs = dict(detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
        kwargs.update(self.connection_options)
        self.db = sqlite3.connect(self.hist_file, **kwargs)
        self.db.execute("""CREATE TABLE IF NOT EXISTS sessions (session integer
                        primary key autoincrement, start timestamp,
                        end timestamp, num_cmds integer, remark text)""")
        self.db.execute("""CREATE TABLE IF NOT EXISTS history
                (session integer, line integer, source text, source_raw text,
                PRIMARY KEY (session, line))""")
        # Output history is optional, but ensure the table's there so it can be
        # enabled later.
        self.db.execute("""CREATE TABLE IF NOT EXISTS output_history
                        (session integer, line integer, output text,
                        PRIMARY KEY (session, line))""")
        self.db.commit() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:history.py

示例4: cleanup_database

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def cleanup_database(days=1):
    """
    remove any PDFs which have been here for more than
    1 day, then compact the database
    """
    log.info('Cleaning up database')
    conn = sqlite3.connect(robotreviewer.get_data('uploaded_pdfs/uploaded_pdfs.sqlite'),
                           detect_types=sqlite3.PARSE_DECLTYPES)

    d = datetime.now() - timedelta(days=days)
    c = conn.cursor()
    c.execute("DELETE FROM article WHERE timestamp < datetime(?) AND dont_delete=0", [d])
    conn.commit()
    conn.execute("VACUUM") # make the database smaller again
    conn.commit()
    conn.close() 
开发者ID:ijmarshall,项目名称:robotreviewer,代码行数:18,代码来源:app.py

示例5: __init__

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def __init__(self, bot):
        self.bot = bot
        self.db = sqlite3.connect(SQLDB, detect_types=sqlite3.PARSE_DECLTYPES)
        self.db.row_factory = sqlite3.Row

        with self.db as con:
            con.executescript(INIT_SQL)

            if check_fts4():
                self.has_fts = True
                con.executescript(FTS_SQL)
                con.create_function('bm25', -1, bm25)
            else:
                self.has_fts = False

        self.bot.loop.create_task(self._populate_userinfo())
        self.bot.loop.create_task(self._upgrade_210())
        self._upgrade_211()
        self._upgrade_230()

        try:
            self.analytics = CogAnalytics(self)
        except Exception as e:
            self.bot.logger.exception(e)
            self.analytics = None 
开发者ID:calebj,项目名称:calebj-cogs,代码行数:27,代码来源:serverquotes.py

示例6: __init__

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def __init__(self, filename, debug = False, logLevel = 'INFO'):
        if filename == ':memory:':
            self.dbname = ""
        else:
            if not filename.lower().endswith(DB_EXTENSION):
               self.dbname = "{}.{}".format(filename, DB_EXTENSION)
            else:
               self.dbname = filename
        self._engine = create_engine("sqlite:///{}".format(self.dbname), echo = debug,
            connect_args={'detect_types': sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES},
        native_datetime = True)

        self._session = orm.Session(self._engine, autoflush = False, autocommit = False)
        self._metadata = Base.metadata
        #loadInitialData(Node)
        Base.metadata.create_all(self.engine)
        meta = MetaData(schema_version = CURRENT_SCHEMA_VERSION)
        self.session.add(meta)
        self.session.flush()
        self.session.commit()
        self._closed = False 
开发者ID:christoph2,项目名称:pyA2L,代码行数:23,代码来源:__init__.py

示例7: __init__

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def __init__(self, db_path, writeable=False, translate_ncbi_namespace=False, check_same_thread=True):
        self._db_path = db_path
        self._db = None
        self._writeable = writeable
        self.translate_ncbi_namespace = translate_ncbi_namespace

        if self._writeable:
            self._upgrade_db()
        self._db = sqlite3.connect(self._db_path,
                                   check_same_thread=check_same_thread,
                                   detect_types=sqlite3.PARSE_DECLTYPES)
        self._db.row_factory = sqlite3.Row
        schema_version = self.schema_version()
        # if we're not at the expected schema version for this code, bail
        if schema_version != expected_schema_version:    # pragma: no cover
            raise RuntimeError("Upgrade required: Database schema"
                               "version is {} and code expects {}".format(schema_version, expected_schema_version))

    # ############################################################################
    # Special methods 
开发者ID:biocommons,项目名称:biocommons.seqrepo,代码行数:22,代码来源:seqaliasdb.py

示例8: migrate_db_v1_to_v2

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def migrate_db_v1_to_v2(db_path):
    old_db_path = db_path + datetime.now().strftime("%s") + ".bkp_db_v1"
    os.rename(db_path, old_db_path)

    old_db = sql.connect(old_db_path,
                         detect_types=sql.PARSE_DECLTYPES |
                         sql.PARSE_COLNAMES)
    new_db = DB(db_path)
    old_db.cursor().execute("PRAGMA foreign_keys = ON")

    epoch_list = []
    for epoch, schema in old_db.execute('SELECT epoch, schema '
                                        'FROM snapshots_schemas'):
        new_db.add_snapshot(epoch, schema)
        epoch_list.append(epoch)

    for epoch in epoch_list:
        file_list = list(old_db.execute("SELECT keyspace, tablename, file "
                                        "FROM snapshots_files WHERE epoch = ?",
                                        (epoch,)))
        new_db.add_snapshot_files(epoch, file_list) 
开发者ID:helpshift,项目名称:scyllabackup,代码行数:23,代码来源:migrate.py

示例9: record_daily

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def record_daily(channelid, channelname, title, start, stop):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")
    title = title.decode("utf8")
    title = xbmcgui.Dialog().input(_("% is Wildcard"), title).decode("utf8")

    start = timestamp2datetime(float(start))
    stop = timestamp2datetime(float(stop))

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    #TODO problem with PRIMARY KEYS, UNIQUE and TIMESTAMP
    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND start=? AND stop =? AND type=?', (channelid, channelname, title, start, stop, "DAILY")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, start, stop, type) VALUES(?, ?, ?, ?, ?, ?)",
        [channelid, channelname, title, start, stop, "DAILY"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:25,代码来源:main.py

示例10: record_weekly

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def record_weekly(channelid, channelname, title, start, stop):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")
    title = title.decode("utf8")
    title = xbmcgui.Dialog().input(_("% is Wildcard"), title).decode("utf8")

    start = timestamp2datetime(float(start))
    stop = timestamp2datetime(float(stop))

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    #TODO problem with PRIMARY KEYS, UNIQUE and TIMESTAMP
    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND start=? AND stop =? AND type=?', (channelid, channelname, title, start, stop, "WEEKLY")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, start, stop, type) VALUES(?, ?, ?, ?, ?, ?)",
        [channelid, channelname, title, start, stop, "WEEKLY"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:25,代码来源:main.py

示例11: record_always_search

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def record_always_search(channelid, channelname):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")

    title = xbmcgui.Dialog().input("IPTV Recorder: " + _("Title Search (% is wildcard)?")).decode("utf8")
    if not title:
        return

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND type=?', (channelid, channelname, title, "SEARCH")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, type) VALUES(?, ?, ?, ?)",
        [channelid, channelname, title, "SEARCH"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:23,代码来源:main.py

示例12: record_always_search_plot

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def record_always_search_plot(channelid, channelname):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")

    description = xbmcgui.Dialog().input("IPTV Recorder: " + _("Plot Search (% is wildcard)?")).decode("utf8")
    if not description:
        return

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND description=? AND type=?', (channelid, channelname, description, "PLOT")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, description, type) VALUES(?, ?, ?, ?)",
        [channelid, channelname, description, "PLOT"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:23,代码来源:main.py

示例13: watch_daily

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def watch_daily(channelid, channelname, title, start, stop):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")
    title = title.decode("utf8")
    title = xbmcgui.Dialog().input(_("% is Wildcard"), title).decode("utf8")

    start = timestamp2datetime(float(start))
    stop = timestamp2datetime(float(stop))

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    #TODO problem with PRIMARY KEYS, UNIQUE and TIMESTAMP
    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND start=? AND stop =? AND type=?', (channelid, channelname, title, start, stop, "WATCH DAILY")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, start, stop, type) VALUES(?, ?, ?, ?, ?, ?)",
        [channelid, channelname, title, start, stop, "WATCH DAILY"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:25,代码来源:main.py

示例14: watch_weekly

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def watch_weekly(channelid, channelname, title, start, stop):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")
    title = title.decode("utf8")
    title = xbmcgui.Dialog().input(_("% is Wildcard"), title).decode("utf8")

    start = timestamp2datetime(float(start))
    stop = timestamp2datetime(float(stop))

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    #TODO problem with PRIMARY KEYS, UNIQUE and TIMESTAMP
    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND start=? AND stop =? AND type=?', (channelid, channelname, title, start, stop, "WATCH WEEKLY")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, start, stop, type) VALUES(?, ?, ?, ?, ?, ?)",
        [channelid, channelname, title, start, stop, "WATCH WEEKLY"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:25,代码来源:main.py

示例15: watch_always

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import PARSE_DECLTYPES [as 别名]
def watch_always(channelid, channelname, title):
    channelid = channelid.decode("utf8")
    channelname = channelname.decode("utf8")
    title = title.decode("utf8")
    title = xbmcgui.Dialog().input(_("% is Wildcard"), title).decode("utf8")

    conn = sqlite3.connect(xbmc.translatePath('%sxmltv.db' % plugin.addon.getAddonInfo('profile')), detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
    cursor = conn.cursor()

    rule = cursor.execute('SELECT * FROM rules WHERE channelid=? AND channelname=? AND title=? AND type=?', (channelid, channelname, title, "WATCH ALWAYS")).fetchone()

    if not rule:
        conn.execute("INSERT OR REPLACE INTO rules(channelid, channelname, title, type) VALUES(?, ?, ?, ?)",
        [channelid, channelname, title, "WATCH ALWAYS"])

    conn.commit()
    conn.close()

    service() 
开发者ID:primaeval,项目名称:plugin.video.iptv.recorder,代码行数:21,代码来源:main.py


注:本文中的sqlite3.PARSE_DECLTYPES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。