0
I’m creating an application that connects to db Sqlite, query and returns the column of the table in question, the problem is that the returned result without formatting comes like this : ( u'Field 1, Field 2' )
, to print I tried to use a for
inside for
and printing each field with a print ( '{0} {1} ... '.format ( ... ) ) ,
and a end = '\n'
at the end to be well formatted, but Pyhton does not accept and I need this to be very dynamic because the number of items can vary with each created db ( User chooses fields and types ), I searched a little but I did not find a good way to print this data, would be grateful if you could send references or explanations.
print ( '{0} {1} ... '.format ( ... ), end = '\n' )
Seria this that you need.
– gato
No, because in this example you sent it specifies how many items will be printed :
'Nome : {} Idade : {} Cpf : {}'.format ( campo [1], campo [2], campo [3] )
and in my case I have no way of knowing how many fields the user added, so if I put ' static ' in this way the application breaks into another db that has more fields.– Luis Souza
Vc needs to concatenate the string dynamically?
– gato
Give me an example of data entry, and the output you want?
– gato
Entree :
( 'Table-Name', ( 'Name text', 'Age integer' ... n ) )
, exit :Darth Vader 300 ...
, yes, concatenate her dynamically.– Luis Souza
Then you will only display the values?
– gato
What you call "input", is the return of the function that reads the table? Is it a tuple of tuples? It’s a bit confusing, it would be interesting if you put the code of this function.
– Sidon
I will only display, I am not in the notbook that the code is at this time, that ' input ' are the arguments that I have to pass to the table ( Information being added in the table ), the output are the values that are obtained by a select no
cursor
, summarizing ... don’t mind Db, just printing, I just need to print it here( u ' Bla, Bla, Bla ' )
in this way :Bla Bla Bla
– Luis Souza