django and mysql connection problem

2011-01-31 Thread cuteangel

its my first project with django..i already tried the connection with
sqlite.but now m using django's connection with mysql n m getting
following error...

D:\project\wogma>manage.py syncdb
Traceback (most recent call last):
  File "D:\project\wogma\manage.py", line 11, in 
execute_manager(settings)

  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
340, in execute_manager
utility.execute()

  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 192,
 in run_from_argv
self.execute(*args, **options.__dict__)

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 218,
 in execute
self.validate()

  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 246,
 in validate
num_errors = get_validation_errors(s, app)

  File "C:\Python26\lib\site-packages\django\core\management
\validation.py", lin
e 65, in get_validation_errors
connection.validation.validate_field(e, opts, f)

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\validation.py", l
ine 8, in validate_field
db_version = connection.get_server_version()

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 27
7, in get_server_version
self.cursor()

  File "C:\Python26\lib\site-packages\django\db\backends\__init__.py",
line 56,
in cursor
cursor = self._cursor(settings)

  File "C:\Python26\lib\site-packages\django\db\backends\mysql
\base.py", line 26
2, in _cursor
self.connection = Database.connect(**kwargs)

  File "C:\Python26\lib\site-packages\MySQLdb\__init__.py", line 81,
in Connect
return Connection(*args, **kwargs)
  File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line
188, in __in
it__
super(Connection, self).__init__(*args, **kwargs2)

_mysql_exceptions.OperationalError: (1049, "Unknown database 'd:/
project/wogma/w
ogma'")

i did the commands in mysql as follows..i already created the wogma
database just using create database n i granted the priviliges..in
mysql. whts the prb??

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django and mysql connection problem

2011-01-31 Thread cuteangel
thnkzit helped...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem in returning the value.

2011-02-23 Thread cuteangel
this is the class from models.py-
class NatPar(models.Model):
@staticmethod
def handle_review(self):
try:
grammar=nltk.parse_cfg("""
S->VP NP
PP->P N
NP->Det N PP
VP->V Det
Det ->'me'|'the'
N->'review'|'DON'
V->'Give'
P->'of'
""")
sent=['Give','me','the','review','of','DON']
parser=nltk.ChartParser(grammar)
trees=parser.nbest_parse(sent)
for tree in trees:
print tree
tokens=find_all_NP(tree)
print tokens
return tokens
except:
return None



def find_all_NP(tree):
if  type(tree)==type('string'):
return None

if tree.node=='NP':
return '-'.join(tree.leaves())

return [npstr for npstr in [find_all_NP(node) for node in
tree[0:]] if npstr]


and calling function is like this-

response=NatPar.handle_review

return render_to_response('review1.html',
{'response':response})

and its displays template like this--



 so what's the problem in handle review..I already checked
the code on python shell n its working there.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to declare a list in django models.py class

2011-02-23 Thread cuteangel
how to declare a list in django models.py class

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



getting u'string' at the beginning of each item in a list

2011-03-17 Thread cuteangel
 def search_mov(movie_name):
try:
from django.db import connection, transaction
cursor = connection.cursor()
cursor.execute("select query from Winteract_Wogmainteract
where query like %s",['%'+movie_name+'%'])
row = cursor.fetchall()
print row
return row

its the function from models.py..
the problem is its returning the correct result,but its appending u
character to the beginning of each item in the result list..it is
printing the list as follows::
((u'Bow Barracks Forever',), (u'Shrek Forever After',))
((u'Shrek Forever After',),)
m passing movie_name as shrek forever after
I dont want the u character to the beginning of each item..I already
tried str() method but its not working...so plz help me in this...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.