apache - Starting with Python 3 and Avro 1.7.6, what are the steps? (Q&A) -


This is a Q & A, which means that I am sharing my solution / answer to a problem I had to face:

The problem was that Apache was not completely-to-date from the site and after some pointing, I manage to do sample work.

  1. Go to the PE3 subfolder under the Lie and build the project through your python 3 (read more)
  2. Create user.avsc in the same folder as the Python code is going to be located. "Name": "name": "name": "name": "name": "name": "name.exe", "name": "name": "name", " Name ":" {user} "," field ": [{" name ":" name ":" type ":" string "}, type": [int "," null "]}, {" name ":" Favorite code "," Type ": [" string "," blank "]}]}

  3. Make .py from the code below (note that I have to make a small change in the code to work).

    The modified code is as follows:

      import avro.schema from avro.datafile Import DataFileReader, Aveiro .io import data Reader, DataMutter schema = avro. DataFileWriter from Open ("user.avsc"). Read ()) Author = DataFile Witter (open ("users.avro", "wb"), DataMriter (), schema) Author .append ({"name": "ben", "favorite_number": 7, "favorite_dill": "red"}) author .append ({"name": "elisa", "favorite_number": 256}) author .append () (Reader.close): reader.close () reader.close ()  
    for reader reader (open "users.avro", "rb") for user in reader reader Li>

  1. Lease wget
  2. Go to py3 subfolder under Lang and me to read your Python project (over through 3)
  3. The user in the same folder. Create ASC because the Pyro code is going to be located. "Name": "name", "name", "name", "name", "name": "name", "type": "name": "

    "", "Name": "user", "field": [type ":" string "}, {" name ":" favorite_number "," type ": [" int "," null "]}, {" Name ":" Favorite Tag "," Type ": [" String "" Zero "]}]}

  4. Generate .py from the code below ( Note that I had to make minor changes to the code to get this to work).

    The revised code is as follows.

      avro.schema Import dataFileReader, DataFileWriter DatumReader from Data Import, DataMriter schema = ("User.avsc") ("user.avsc"). Read ()) Author = Datafilter (open ("users.avro" , "Wb"), datam authors (), schema) author.append ({"name": "elisa", "favorite_number": 256}) author .append ({"name": "ben", "favorite_number" 7, "favorite_desk": "red"}) writer.close () reader = DataFileReader reader for user ("users.avro", "rb"), data reader ()): print (user) reader.close ( )  

Comments