Dear ALL, 

i am trying to connect my website to a mysql database using this connection 
string db = DAL('mysql://i3zif_user:i3zif@localhost/i3zif_test')  and i 
keep getting this :




ERROR TICKET FOR "I3ZIF2"
TICKET ID
127.0.0.1.2012-06-06.07-02-36.d2515abd-2f82-4ed8-aef8-e1e52b134cd7

<class 'gluon.contrib.pymysql.err.ProgrammingError'> (1064, u"You have an 
error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'Like INT,\n 
Show_on_SideBar CHAR(1),\n Home_Page_Video CHAR(1),\n Order_Nu' at line 22")
VERSION
web2py™    (1, 99, 4, datetime.datetime(2011, 12, 14, 14, 46, 14), 'stable')
Python    
TRACEBACK

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 204, in restricted
    exec ccode in environment
  File "C:/web2py/applications/i3zif2/models/db.py", line 255, in <module>
    Field('Order_Number','integer')
  File "C:\web2py\gluon\dal.py", line 5097, in define_table
    polymodel=polymodel)
  File "C:\web2py\gluon\dal.py", line 705, in create_table
    self.create_sequence_and_triggers(query,table)
  File "C:\web2py\gluon\dal.py", line 1348, in create_sequence_and_triggers
    self.execute(query)
  File "C:\web2py\gluon\dal.py", line 1359, in execute
    return self.log_execute(*a, **b)
  File "C:\web2py\gluon\dal.py", line 1353, in log_execute
    ret = self.cursor.execute(*a, **b)
  File "C:\web2py\gluon\contrib\pymysql\cursors.py", line 108, in execute
    self.errorhandler(self, exc, value)
  File "C:\web2py\gluon\contrib\pymysql\connections.py", line 184, in 
defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, u"You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right syntax 
to use near 'Like INT,\n    Show_on_SideBar CHAR(1),\n    Home_Page_Video 
CHAR(1),\n    Order_Nu' at line 22")
IN FILE: C:\WEB2PY\APPLICATIONS\I3ZIF2\MODELS\DB.PY
# -*- coding: utf-8 -*-

#########################################################################
## Made By Hassan Alnatour
## Powerd By GardeniaTelco
#########################################################################

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request.env.web2py_runtime_gae:
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL('mysql://i3zif_user:i3zif@localhost/i3zif_test')
    #db=DAL('sqlite://storage.sqlite')
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    ## store sessions and tickets there
    session.connect(request, response, db = db)
    ## or store session in Memcache, Redis, etc.
    ## from gluon.contrib.memdb import MEMDB
    ## from google.appengine.api.memcache import Client
    ## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'

#########################################################################
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db, hmac_key=Auth.get_or_create_key())
crud, service, plugins = Crud(db), Service(), PluginManager()

#auth.settings.custom_fields['auth_user'].append()
genders = ['Male','Female']
## customize auth
auth.settings.extra_fields['auth_user']= [
  Field('Country'),
  Field('City'),
  Field('gender',requires=IS_IN_SET(genders,zero=None)),
  Field('Age','integer'),
  
Field('agree_to_terms','boolean',requires=IS_NOT_EMPTY(error_message='Dear 
User You Must Argee To Service Terms'))
  #Field('complete_registration',default=False,update=True,writable=False, 
readable=False),
  #Field('completed_registration',default="False",writable=False, 
readable=False)
  ]

#if auth.user and auth.user.complete_registration == False:
#   if not (request.controller,request.function) == ('default','user'):
#       redirect(URL('default', 'user', args='profile'))

## create all tables needed by auth if not custom tables
lan = request.controller
auth.define_tables()
auth.settings.register_next = URL(lan,'index')
auth.settings.profile_next = URL(lan,'index')
auth.settings.login_next = URL(lan,'index')
auth.settings.logout_next = URL(lan,'index')

## configure email
mail=auth.settings.mailer
mail.settings.server ='smtp.gmail.com:587'  # your SMTP server
mail.settings.sender = '.......'         # your email
mail.settings.login = 'i..........'       # your credentials or None


## configure auth policy

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.messages.verify_email = 'Click on the link http://' + \
    'i3zif.com' + \
    URL(r=request,c='arabic',f='user',args=['verify_email']) + \
    '/%(key)s to verify your email Then you can open your account ;)'
auth.messages.reset_password = 'Click on the link http://' + \
    'i3zif.com' + \
    URL(r=request,c='arabic',f='user',args=['reset_password']) + \
    '/%(key)s to reset your password'

## if you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
## register with janrain.com, write your domain:api_key in 
private/janrain.key
#from gluon.contrib.login_methods.rpx_account import use_janrain
#use_janrain(auth,filename='private/janrain.key')
from gluon.contrib.login_methods.rpx_account import RPXAccount
url = "http://localhost:8000/%s/default/user/login"; % request.application
from gluon.contrib.login_methods.extended_login_form import 
ExtendedLoginForm
other_form = RPXAccount(request, 
api_key='a096b5b9ccb5cdecb2d29ab993746e10338b4d3b', domain='hassanalnator', 
url=url)
auth.settings.login_form = ExtendedLoginForm(auth,other_form)
    
#########################################################################
## Define your tables below (or better in another model file) for example
##
## >>> db.define_table('mytable',Field('myfield','string'))
##
## Fields can be 'string','text','password','integer','double','boolean'
##       'date','time','datetime','blob','upload', 'reference TABLENAME'
## There is an implicit 'id integer autoincrement' field
## Consult manual for more options, validators, etc.
##
## More API examples for controllers:
##
## >>> db.mytable.insert(myfield='value')
## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
## >>> for row in rows: print row.id, row.myfield
#########################################################################
from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)
ckeditor.define_tables()
widget=ckeditor.widget

now = request.now

 ### Instruments :###
db.define_table('Instruments',Field('Instrument_name'),Field('Instrument_Arabic_name'),Field('Image','upload'))

db.define_table('Styles',Field('Style'),Field('Arabic_Style'))
styles = []
for s in db().select(db.Styles.Style):
    styles.append(str(s.Style))
pass


### multiselect widget ###
def multiselect_widget(f,v):
    import uuid
    d_id = "multiselect-" + str(uuid.uuid4())[:8]
    wrapper = DIV(_id=d_id)
    inp = SQLFORM.widgets.options.widget(f,v)
    inp['_multiple'] = 'multiple'
    inp['_style'] = 'min-width: %spx;' % (len(f.name) * 20 + 50)
    if v:
        if not isinstance(v,list): v = str(v).split('|')
        opts = inp.elements('option')
        for op in opts:
            if op['_value'] in v:
                op['_selected'] = 'selected'            
    scr = SCRIPT('jQuery("#%s select").multiSelect({'\
                 'noneSelected:"Select %ss"});' % (d_id,f.name))
    wrapper.append(inp)
    wrapper.append(scr)
    if request.vars.get(inp['_id']+'[]',None):
        var = request.vars[inp['_id']+'[]']
        if not isinstance(var,list): var = [var]
        request.vars[f.name] = var
        del request.vars[inp['_id']+'[]']
    return wrapper
    
    
def youtube(url):
    video_url = url
    urllist=video_url.split("v=")
    return urllist[1]
       
 ### Teachers :###
db.define_table('Teachers',
                Field('Name'),
                Field('Arabic_Name'),
                Field('Instroument',db.Instruments),
                Field('Image','upload'),
                Field('About','text'),
                Field('Arabic_About','text'),
                Field('Youtube_Video_Url'),
                Field('Style'),
                Field('Country')
  
                )
db.Teachers.Style.requires = IS_IN_SET(styles,multiple=True)
db.Teachers.Style.widget = multiselect_widget
                

#db.Teachers.User_id.requires=IS_IN_DB(db,db.auth_user.id,'%(first_name)s 
%(last_name)s')
db.Teachers.Instroument.requires=IS_IN_DB(db,db.Instruments.id,'%(Instrument_name)s')


Course_level = ['Beginner','Intermediate','Advanced'] 
Video_type = ['Independent video','Course Video','Song Video']

 ### Videos :###

###Teachers List###################################################### 
#myTeachers = []
#databaseTeachers = db(db.auth_user.id==db.Teachers.User_id).select()
#for teacher in databaseTeachers:
#    myTeachers.append(str(teacher.auth_user.first_name+' 
'+teacher.auth_user.last_name))
#pass
####################################################################
####################################################################
#myInstruments = []
#for ins in db().select(db.Instruments.Instrument_name):
#    myInstruments.append(str(ins.Instrument_name))
#pass
####################################################################

db.define_table('Courses',
                Field('Title'),
                Field('Arabic_Title'),
                Field('Instrument',db.Instruments),
                
                Field('Level',requires=IS_IN_SET(Course_level,zero=None)),
                Field('Description','text'),
                Field('Arabic_Description','text'),
                Field('Cover','upload'),
                Field('Price','integer'),
                Field('Order_Number','integer'))
db.Courses.Instrument.requires=IS_IN_DB(db,db.Instruments.id,'%(Instrument_name)s')
###Courses List###################################################### 


MyCourses = ['None']
for coures in db().select(db.Courses.Title):
    MyCourses.append(str(coures.Title))
pass


db.define_table('Songs',Field('Song_Name'),Field('Song_Arabic_Name'),Field('Artist'),Field('Artist_Arabic'))


db.define_table('Videos',
                Field('Title'),
                Field('Hits','integer',default=1),
                Field('Arabic_Title'),
                Field('Bits_on_The_Run_Script'),
                Field('Youtube_Video_Url'),
                Field('Description','text',length=1000),
                Field('Arabic_Description','text',length=1000),
                Field('Publish_Date','datetime',default=now),
                Field('Teacher',db.Teachers),
                Field('Instroument',db.Instruments),
                Field('Level',requires=IS_IN_SET(Course_level,zero=None)),
                Field('Style'),
                
Field('Video_Type',requires=IS_IN_SET(Video_type,zero=None)),
                Field('Course_ID'),
                Field('Song_ID',db.Songs),
                Field('Price',default=0),
                Field('Full_Course_Price',default=0),
                Field('Cover','upload'),
                Field('PDF','upload'),
                
                Field('Like','integer',default=1),
                Field('Show_on_SideBar','boolean'),
                Field('Home_Page_Video','boolean'),
                Field('Order_Number','integer')
                
                
                )
db.Videos.Style.requires = IS_IN_SET(styles,multiple=True)
db.Videos.Style.widget = multiselect_widget

   
db.Videos.Song_ID.requires=IS_EMPTY_OR(IS_IN_DB(db,db.Songs.id,'%(Song_Name)s'))
db.Videos.Course_ID.requires=IS_EMPTY_OR(IS_IN_DB(db,db.Courses.id,'%(Title)s'))
db.Videos.Teacher.requires=IS_IN_DB(db,db.Teachers.id,'%(Name)s')
db.Videos.Instroument.requires=IS_IN_DB(db,db.Instruments.id,'%(Instrument_name)s')

db.define_table('BlogPost',
                Field('Title'),
                Field('Arabic_Title'),
                Field('Post','text'),
                Field('Arabic_Post','text'),
                
Field('DateTime','datetime',default=now,readable=False,writable=False)
                )


db.define_table('UserPaidVideos',
                Field('User_ID',db.auth_user),
                Field('Video_ID',db.Videos),
                Field('transaction_id')
               
                )
#videos = []                
#for v in db(db.Videos.Price != "0").select(db.Videos.ALL):
#    videos.append(v.id)
#pass
#db.UserPaidVideos.Video_ID.requires = IS_IN_SET(videos,multiple=True)
#db.UserPaidVideos.Video_ID.widget = multiselect_widget

db.UserPaidVideos.User_ID.requires=IS_IN_DB(db,db.auth_user.id,'%(first_name)s')

#db.UserPaidVideos.Video_ID.requires=IS_IN_DB(db,db.Videos.id,'%(English_Title)s')


#plugins.instant_admin.extra_sidebar_title = "Videos Tracking"
#plugins.instant_admin.extra_sidebar = [
#    A('Video Analytics', _href='http://analytics.anvato.com/profiles')
    
#]

db.define_table("Song_Slider",Field("quantity","integer", default=0))

place = ['top','right','left']

db.define_table('Adds',Field('Place',requires = 
IS_IN_SET(place)),Field('Content','upload'),Field('is_Flash','boolean'))

places = ['topleft','topright','bottomleft','bottomright','none']
db.define_table('HomeBlocks',Field('Place', requires 
=IS_IN_SET(places)),Field('Content','text',widget=ckeditor.widget),Field('Arabic_Content','text',widget=ckeditor.widget))



db.define_table('Counter',Field('number','integer'))

db.define_table('ContactsUs',Field('Name'),Field('question','text'))

db.define_table('Newsletter',Field('Email'))

db.define_table('ticker',Field('Arabic_News'),Field('English_News'),Field('link'),Field('English_link'))

db.define_table('UserContent',Field('Title'),Field('description','text'),Field('Link'),Field('Approved','boolean'))


def getname(id):
        row = db.auth_user[id]
        if auth.is_logged_in():
            return row.first_name +' '+ row.last_name
        else:
            return None
    

db.define_table('Tabs',Field('user',default=getname(auth.user_id)),Field('Song_Name'),Field('Artist'),Field('Tabs','text',widget=ckeditor.widget),Field('Date','date',default=request.now),Field('Approved','boolean'))


db.define_table('Chords',Field('Chord'),Field('image','upload'))
Powered by web2py™ created by Massimo Di Pierro ©2007-2011 - Admin 
language  

Reply via email to