I only have a limited understanding of what a restful interface is. Is
it an interface where all the data is inputted in the url and then
outputted as xml or json?
I was thinking something more a ong the lines of building a class like
this:
class MySQLDB(DB):
def __init__(self, **keywords):
import MySQLdb as db
if 'pw' in keywords:
keywords['passwd'] = keywords['pw']
del keywords['pw']
if 'charset' not in keywords:
keywords['charset'] = 'utf8'
elif keywords['charset'] is None:
del keywords['charset']
self.paramstyle = db.paramstyle = 'pyformat' # it's both, like
psycopg
self.dbname = "mysql"
self.supports_multiple_insert = True
DB.__init__(self, db, keywords)
def _process_insert_query(self, query, tablename, seqname):
return query, SQLQuery('SELECT last_insert_id();')
class SqliteDB(DB):
def __init__(self, **keywords):
try:
import sqlite3 as db
db.paramstyle = 'qmark'
except ImportError:
try:
from pysqlite2 import dbapi2 as db
db.paramstyle = 'qmark'
except ImportError:
import sqlite as db
self.paramstyle = db.paramstyle
keywords['database'] = keywords.pop('db')
self.dbname = "sqlite"
DB.__init__(self, db, keywords)
def _process_insert_query(self, query, tablename, seqname):
return query, SQLQuery('SELECT last_insert_rowid();')
def query(self, *a, **kw):
out = DB.query(self, *a, **kw)
if isinstance(out, iterbetter):
# rowcount is not provided by sqlite
del out.__len__
return out
# as with PostgresDB, the database is assumed to be in UTF-8.
# This doesn't mean we turn byte-strings coming out of it into
# Unicode objects, but we avoid trying to put Unicode objects into
# it.
encoding = 'UTF-8'
def _py2sql(self, val):
r"""
Work around a couple of problems in SQLite that maybe pysqlite
should take care of: give it True and False and it thinks
they're column names; give it Unicode and it tries to insert
it in, possibly, ASCII.
>>> meth = SqliteDB(db='nonexistent')._py2sql
>>> [meth(x) for x in [True, False, 1, 2, 'foo', u'souffl
\xe9']]
[1, 0, 1, 2, 'foo', 'souffl\xc3\xa9']
"""
if val is True: return 1
elif val is False: return 0
elif isinstance(val, unicode): return val.encode
(self.encoding)
else: return val
...But using GQL. I think this would be a tremendous innovation for
webpy. Right now, anyone building for App Engine has to deeply
integrate their code with their proprietary system of queries. Imagine
if webpy was known as the easiest and simplest framework to use with
GAE, and thens hould you choose--to stop using with GAE.
-Alan
On Dec 28, 11:13 am, leone <[email protected]> wrote:
> I am interested, but I have not found any web-service about Google Big
> Table.
> I suppose you must write a GAE application, deploy on Google servers
> and run it as
> a RESTful interface to your webpy application.
>
> On Dec 28, 6:05 am, adelevie <[email protected]> wrote:
>
> > I am wondering if there is any interest in a database wrapper for
> > Google App Engine. Such a wrapper would make it much easier to move a
> > web.py app to google app engine--simply change the database parameters
> > and write a few classes, as opposed to rewriting every single web.db
> > query into app engine queries. This seems possible because GQL is
> > essentially SQL. I have no experience with creating db backends, but
> > I'd like to help in any way possible if others are also interested.
>
> > -Alan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---