#!/usr/bin/env python #coding: utf-8 from fdb import connect, Error def fb_conn(): try: # The server is named 'bison'; the database file is at '/temp/test.db'. return (None,connect(sn='bison:/temp/test.db', user='sysdba', password='pass', charset='UTF8')) except Error, erro: return ('error',erro)
def login(id,password): connection = fb_conn() if connection[0] == 'error': return ('error',connection[1]) con = connection[1] try: cursor = con.cursor() cursor.execute(''' select * from users) where (id = %s) ''' % id ) # returning 1 record data = cursor.fetchone() cursor.execute(''' select * from any_data) where (id > %s) ''' % id ) # returning multiple records data = cursor.fetchall() con.close() return (None, data) except Error, erro: con.close() return ('erro', erro)