Ejemplo n.º 1
0
lat = 37.85
lon = -122.78
try:
	c.execute("INSERT INTO PCID VALUES (?,?,?)",\
	 (PCID, first_name, family_name))
except:
	pass

try: 
	c.execute("INSERT INTO CHECKIN VALUES (?,?)",\
	 (No_to, code))
except:
	pass

try:
	c.execute("INSERT INTO CONTENT VALUES (?,?,?,?,?,?,?,?)",\
	 (ContentID, PCID, timestamp, title, content, imageID, lat, lon))
except:
	pass
	
imagedata = open('Happy_cat.jpg', "rb").read()	 

try:
	c.execute("INSERT INTO IMAGE VALUES (?,?)",\
	 (imageID, sqlite.encode(sqlite.Binary(imagedata))))
except:
	pass
	  
conn.commit()

Ejemplo n.º 2
0
 def encode(self, str):
   return sqlite3.encode(str)
Ejemplo n.º 3
0
 def _quote(self):
   print ('=> passing thru _quote()')
   return "'%s'" % sqlite3.encode(self.s)
Ejemplo n.º 4
0
 def __init__(self, filename, autoCommit=1, **kw):
     global sqlite
     global using_sqlite2
     if sqlite is None:
         try:
             import sqlite3 as sqlite
             using_sqlite2 = True
         except ImportError:
             try:
                 from pysqlite2 import dbapi2 as sqlite
                 using_sqlite2 = True
             except ImportError:
                 import sqlite
                 using_sqlite2 = False
     self.module = sqlite
     self.filename = filename  # full path to sqlite-db-file
     self._memory = filename == ':memory:'
     if self._memory:
         if not using_sqlite2:
             raise ValueError(
                 "You must use sqlite2 to use in-memory databases")
     # connection options
     opts = {}
     if using_sqlite2:
         if autoCommit:
             opts["isolation_level"] = None
         if 'encoding' in kw:
             import warnings
             warnings.warn(DeprecationWarning("pysqlite2 does not support the encoding option"))
         opts["detect_types"] = sqlite.PARSE_DECLTYPES
         for col_type in "text", "char", "varchar", "date", "time", "datetime", "timestamp":
             sqlite.register_converter(col_type, stop_pysqlite2_converting_strings)
             sqlite.register_converter(col_type.upper(), stop_pysqlite2_converting_strings)
         try:
             from sqlite import encode, decode
         except ImportError:
             import base64
             sqlite.encode = base64.encodestring
             sqlite.decode = base64.decodestring
         else:
             sqlite.encode = encode
             sqlite.decode = decode
         global sqlite2_Binary
         if sqlite2_Binary is None:
             sqlite2_Binary = sqlite.Binary
             sqlite.Binary = lambda s: sqlite2_Binary(sqlite.encode(s))
         if 'factory' in kw:
             factory = popKey(kw, 'factory')
             if isinstance(factory, str):
                 factory = globals()[factory]
             opts['factory'] = factory(sqlite)
     else:
         opts['autocommit'] = bool(autoCommit)
         if 'encoding' in kw:
             opts['encoding'] = popKey(kw, 'encoding')
         if 'mode' in kw:
             opts['mode'] = int(popKey(kw, 'mode'), 0)
     if 'timeout' in kw:
         if using_sqlite2:
             opts['timeout'] = float(popKey(kw, 'timeout'))
         else:
             opts['timeout'] = int(float(popKey(kw, 'timeout')) * 1000)
     if 'check_same_thread' in kw:
         opts["check_same_thread"] = bool(popKey(kw, 'check_same_thread'))
     # use only one connection for sqlite - supports multiple)
     # cursors per connection
     self._connOptions = opts
     self.use_table_info = popKey(kw, "use_table_info", False)
     DBAPI.__init__(self, **kw)
     self._threadPool = {}
     self._threadOrigination = {}
     if self._memory:
         self._memoryConn = sqlite.connect(
             self.filename, **self._connOptions)
Ejemplo n.º 5
0
 def encode(self, str):
     return sqlite3.encode(str)