you need to db.commit() after creating the table....

Il giorno mercoledì 10 luglio 2013 09:21:39 UTC+2, Prasad Muley ha scritto:
>
> Hello all,
>                I have created one table called 'Programmer'. Table 
> creation is done successfully but whenever I tried to insert data it shows 
> me errors 'test.Programmer' doesn't exist. I have done in following way.
>
> prankester@Altocumulus: ~ master ⚡
> $ bash cmdweb2py.sh                   [12:37:21]
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2013
> Version 2.6.0-development+timestamp.2013.07.03.01.52.44
> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
> MySQL(MySQLdb), PostgreSQL(pg8000), IMAP(imaplib)
> WARNING:web2py:import IPython error; use default python shell
> Python 2.7.3 (default, Apr 10 2013, 05:46:21) 
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> db=DAL("mysql://root:root@localhost/test")
> >>> db.define_table('Programmer',
> ...                 Field('username',type='string',length=100,unique=True),
> ...                 Field('password',type='password',notnull=True),
> ...                 Field('level',notnull=True),
> ...                 format='%(username)s',
> ...                 migrate=False)
> <Table Programmer (id,username,password,level)>
> >>> db.Programmer.username #table created successfully
> <gluon.dal.Field object at 0x8c17fac>
> >>> 
> db.Programmer.insert(username="Prasad",password="web2py",level="Beginner")
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "/home/prankester/web2py-master/gluon/dal.py", line 8579, in insert
>     ret =  self._db._adapter.insert(self, self._listify(fields))
>   File "/home/prankester/web2py-master/gluon/dal.py", line 1209, in insert
>     raise e
> ProgrammingError: (1146, "Table 'test.Programmer' doesn't exist")
> >>>#what's going on wrong
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to