How to use the apsw.apswversion function in apsw

To help you get started, we’ve selected a few apsw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openaire / iis / iis-3rdparty-madis / src / main / resources / eu / dnetlib / iis / 3rdparty / scripts / madis / functions / __init__.py View on Github external
except ImportError:
    # Python 2.6
    from lib.collections26 import OrderedDict

try:
    from inspect import isgeneratorfunction
except ImportError:
    # Python < 2.6
    def isgeneratorfunction(obj):
        return bool((inspect.isfunction(object) or inspect.ismethod(object)) and
                    obj.func_code.co_flags & CO_GENERATOR)

sys.setcheckinterval(1000)

sqlite_version = apsw.sqlitelibversion()
apsw_version = apsw.apswversion()

VTCREATE = 'create virtual table temp.'
SQLITEAFTER3711 = False
SQLITEAFTER380 = False
sqlite_version_split = [int(x) for x in sqlite_version.split('.')]

if sqlite_version_split[0:3] >= [3,8,0]:
    SQLITEAFTER380 = True

try:
    if sqlite_version_split[0:3] >= [3,7,11]:
        VTCREATE = 'create virtual table if not exists temp.'
        SQLITEAFTER3711 = True
except Exception, e:
    VTCREATE = 'create virtual table if not exists temp.'
    SQLITEAFTER3711 = True
github trakt / Plex-Trakt-Scrobbler / Trakttv.bundle / Contents / Code / libraries.py View on Github external
    @staticmethod
    def test():
        Log.Info('Testing native library support...')

        # Check "apsw" availability
        try:
            import apsw

            Log.Info(' - apsw: available (v%s) [sqlite: %s]', apsw.apswversion(), apsw.SQLITE_VERSION_NUMBER)
        except Exception, ex:
            Log.Error(' - Unable to import "apsw": %s', ex)

        # Check "llist" availability
        try:
            import llist

            Log.Info(' - llist: available')
        except Exception, ex:
            Log.Warn(' - Unable to import "llist": %s', ex)

        # Check "lxml" availability
        try:
            import lxml

            Log.Info(' - lxml: available')
github kovidgoyal / calibre / src / calibre / utils / apsw_shell.py View on Github external
for name in tables:
                    if len(self.db.cursor().execute("select * from "+self._fmt_sql_identifier(stat[0])+" WHERE tbl=?", (name,)).fetchall()):
                        if name not in analyze_needed:
                            analyze_needed.append(name)
            analyze_needed.sort()

            def blank():
                self.write(self.stdout, "\n")

            def comment(s):
                if isinstance(s, bytes):
                    s = s.decode('utf-8', 'replace')
                self.write(self.stdout, textwrap.fill(s, 78, initial_indent="-- ", subsequent_indent="-- ")+"\n")

            pats=", ".join([(x,"(All)")[x=="%"] for x in cmd])
            comment("SQLite dump (by APSW %s)" % (apsw.apswversion(),))
            comment("SQLite version " + apsw.sqlitelibversion())
            comment("Date: " +time.ctime())
            comment("Tables like: "+pats)
            comment("Database: "+self.db.filename)
            try:
                import getpass
                import socket
                comment("User: %s @ %s" % (getpass.getuser(), socket.gethostname()))
            except ImportError:
                pass
            blank()

            comment("The values of various per-database settings")
            comment("PRAGMA page_size="+str(self.db.cursor().execute("pragma page_size").fetchall()[0][0])+";\n")
            comment("PRAGMA encoding='"+self.db.cursor().execute("pragma encoding").fetchall()[0][0]+"';\n")
            vac={0: "NONE", 1: "FULL", 2: "INCREMENTAL"}
github plasticityai / magnitude / pymagnitude / third_party / _apsw / example-code.py View on Github external
py3=sys.version_info >= (3, 0)
def inext(v):  # next value from iterator
    return next(v) if py3 else v.next()


import os
import time
import apsw

###
### Check we have the expected version of apsw and sqlite
###

#@@CAPTURE
print ("      Using APSW file",apsw.__file__)                # from the extension module
print ("         APSW version",apsw.apswversion())           # from the extension module
print ("   SQLite lib version",apsw.sqlitelibversion())      # from the sqlite library code
print ("SQLite header version",apsw.SQLITE_VERSION_NUMBER)   # from the sqlite header file at compile time
#@@ENDCAPTURE

###
### Opening/creating database
###

connection=apsw.Connection("dbfile")
cursor=connection.cursor()

###
### simple statement  @@ example-cursor
###

cursor.execute("create table foo(x,y,z)")
github kovidgoyal / calibre / src / calibre / utils / apsw_shell.py View on Github external
def cmdloop(self, intro=None):
        """Runs the main interactive command loop.

        :param intro: Initial text banner to display instead of the
           default.  Make sure you newline terminate it.
        """
        if intro is None:
            intro="""
SQLite version %s (APSW %s)
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
""" % (apsw.sqlitelibversion(), apsw.apswversion())
            intro=intro.lstrip()
        if self.interactive and intro:
            if sys.version_info<(3,0):
                intro=unicode_type(intro)
            c=self.colour
            self.write(self.stdout, c.intro+intro+c.intro_)

        using_readline=False
        try:
            if self.interactive and self.stdin is sys.stdin:
                import readline
                old_completer=readline.get_completer()
                readline.set_completer(self.complete)
                readline.parse_and_bind("tab: complete")
                using_readline=True
                try:
github plasticityai / magnitude / pymagnitude / third_party / _apsw / tools / shell.py View on Github external
def cmdloop(self, intro=None):
        """Runs the main interactive command loop.

        :param intro: Initial text banner to display instead of the
           default.  Make sure you newline terminate it.
        """
        if intro is None:
            intro="""
SQLite version %s (APSW %s)
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
""" % (apsw.sqlitelibversion(), apsw.apswversion())
            intro=intro.lstrip()
        if self.interactive and intro:
            if sys.version_info<(3,0):
                intro=unicode(intro)
            c=self.colour
            self.write(self.stdout, c.intro+intro+c.intro_)

        using_readline=False
        try:
            if self.interactive and self.stdin is sys.stdin:
                import readline
                old_completer=readline.get_completer()
                readline.set_completer(self.complete)
                readline.parse_and_bind("tab: complete")
                using_readline=True
                try:
github inportb / playground / Pinako / webquery / webquery.py View on Github external
mod = WebQueryModule()
	shell.db.createmodule('webquery',mod)
	loaded = []
	for fn in sys.argv[1:]:
		tbl = re.sub(r'\W','_',fn)
		if tbl.endswith('_yml'):
			tbl = tbl[:-4]
		sql = 'CREATE VIRTUAL TABLE %s USING webquery(%s);'%(tbl,fn)
		try:
			shell.process_sql(sql)
			loaded.append('> '+sql+'\r\n')
		except KeyboardInterrupt:
			raise
		except:
			pass
	shell.cmdloop(intro=('SQLite version %s (APSW %s)\r\nEnter ".help" for instructions\r\nEnter SQL statements terminated with a ";"\r\n'%(apsw.sqlitelibversion(),apsw.apswversion()))+''.join(loaded))
github plasticityai / magnitude / pymagnitude / third_party / _apsw / tools / shell.py View on Github external
for stat in self.db.cursor().execute("select name from sqlite_master where sql not null and type='table' and tbl_name like 'sqlite_stat%'"):
                for name in tables:
                    if len(self.db.cursor().execute("select * from "+self._fmt_sql_identifier(stat[0])+" WHERE tbl=?", (name,)).fetchall()):
                        if name not in analyze_needed:
                            analyze_needed.append(name)
            analyze_needed.sort()

            def blank():
                self.write(self.stdout, "\n")

            def comment(s):
                s=unicodify(s)
                self.write(self.stdout, textwrap.fill(s, 78, initial_indent="-- ", subsequent_indent="-- ")+"\n")

            pats=", ".join([(x,"(All)")[x=="%"] for x in cmd])
            comment("SQLite dump (by APSW %s)" % (apsw.apswversion(),))
            comment("SQLite version " + apsw.sqlitelibversion())
            comment("Date: " +unicodify(time.strftime("%c")))
            comment("Tables like: "+pats)
            comment("Database: "+self.db.filename)
            try:
                import getpass
                import socket
                comment("User: %s @ %s" % (unicodify(getpass.getuser()), unicodify(socket.gethostname())))
            except ImportError:
                pass
            blank()

            comment("The values of various per-database settings")
            self.write(self.stdout, "PRAGMA page_size="+str(self.db.cursor().execute("pragma page_size").fetchall()[0][0])+";\n")
            comment("PRAGMA encoding='"+self.db.cursor().execute("pragma encoding").fetchall()[0][0]+"';\n")
            vac={0: "NONE", 1: "FULL", 2: "INCREMENTAL"}