newbie question:connecting to a database

kavitha thankaian kavithapython at yahoo.co.in
Thu Jan 25 04:55:15 EST 2007


Hi,
   
  I could solve the problem in connecting to a database,,,
  while configuring the daatsourcename by default it gets connected to the master table,,,so there i must specify the database which i like to connect,,,so now i can see the animals table in my database,,
   
  Thanks Eugene,,,
   
  Kavitha

Eugene Antimirov <Eugene.Antimirov at portaone.com> wrote:
  kavitha thankaian wrote:
> Hi,
> 
> i wrote a simple script (which follows) to insert a table in the 
> database.i could execute this query and get the result in python 
> shell.but when i open "my sql enterprise manager" i couldnt find the 
> table"animals".it would be so kind of you if someone could help me,,,
> 
> 
> import dbi
> import odbc
> conn=odbc.odbc("DSN=mydatabase;UID=xxx;PWD=yyy")
> cursor=conn.cursor()
> cursor.execute("Create table animals(parent char(50),child char(50))")
> cursor.execute("insert into animals values('lion','cub')")
> cursor.execute("insert into animals values('goat','lamb')")
> cursor.execute("select * from animals")
> print cursor.fetchall()
> 
> 
> Rgds
> Kavitha
>
> ------------------------------------------------------------------------
You've probably missed cursor.commit() ;)

-- 
Sincerely,
Eugene Antimirov
PortaOne, Inc., SIP Support Engineer
support at portaone.com

* For further Billing and Technical information:
=> Please visit our website http://www.portaone.com
=> Please visit our forum http://forum.portaone.com

* Meet us at Internet Telephony Conference & Expo
* Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322
* http://www.tmcnet.com/voip/conference/

-- 
http://mail.python.org/mailman/listinfo/python-list


 				
---------------------------------
 Here’s a new way to find what you're looking for - Yahoo! Answers 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070125/b3011638/attachment.html>


More information about the Python-list mailing list