in my post below "c" is a variable which is used to execute the SQL 
commands..

we need to send it result in cursor to a variable.

in sqldb it is possible to use below code

x=c.fetchall() - this will save the retrived rows to variable x, but this 
method is giving be error in mysql-python connector.

On Friday, August 24, 2012 11:31:09 AM UTC+5:30, Panupat wrote:
>
> Can you do print variable[0][1] ?
>
>
> On Fri, Aug 24, 2012 at 12:13 PM, PBLN RAO <[email protected]<javascript:>
> > wrote:
>
>> Hi All,
>>
>> i am developing a tool which manages the maya files details in database 
>> (for instance i am using MySQL as database).
>>
>> the data table looks like the attached image.
>>
>> I am using 
>> MySQL-Python-connector<http://dev.mysql.com/downloads/connector/python/>from 
>> MySQL Site.
>>
>> but when i connect and retrieve data i am getting data in tupils. Is 
>> there a way that i can get this data in a table format and can be retrieved 
>> by the column (field) name/index. as we have in datasets .NET application.
>>
>> Result from python:
>>
>> >>> import mysql.connector
>> >>> 
>> conn=mysql.connector.Connect(host='172.16.48.9',user='showtime',password='s1000@ma25db',database='artists_core')
>> >>> c=conn.cursor()
>> >>> c.execute("""SELECT Artist_Name, Artist_ID, Login_ID FROM 
>> artists_core.employee limit 1,10""")
>> >>> for row in c:
>> ...     print row
>> ... 
>> (u'SRINIVASAN G', u'1023', u'srinivasang.1023')
>> (u'ACSARAVANAN', u'1027', u'saravananac.1027')
>> (u'REX ANTHONY R', u'1031', u'rex.1031')
>> (u'SUNIL S', u'1058', u'sunils.1058')
>> (u'C.SRIDHAR REDDY', u'1071', u'csreddy.1071')
>> (u'ARUN PRAKASH', u'1308', u'arunprakash.1308')
>> (u'WINSON A.C.', u'1353', u'winson.1353')
>> (u'BHASKAR D', u'1422', u'bhaskard.1422')
>> (u'RAMA KRISHNA VARMA M.S', u'1458', u'sivam.1458')
>> (u'POORNANANDAM A', u'1510', u'poornanandam.1510')
>>
>> i need an alternate where i can access the data above directly as 
>> variable(row,col)
>>
>> so if i print variable(1,0)
>>
>> it should give me result as 'ACSARAVANAN'
>>
>> In .NET this can be achieved with datasets. can any one tell me how can i 
>> get this in python.
>>
>> -- 
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings: 
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to