How to populate a Django sqlite3 database











up vote
1
down vote

favorite
1












My plan is to collect lawyer biography data from websites in batches and convert each batch into a .csv file, then to json, and then load each into a Django database.



Please let me know how to achieve this task the best way.










share|improve this question




























    up vote
    1
    down vote

    favorite
    1












    My plan is to collect lawyer biography data from websites in batches and convert each batch into a .csv file, then to json, and then load each into a Django database.



    Please let me know how to achieve this task the best way.










    share|improve this question


























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      My plan is to collect lawyer biography data from websites in batches and convert each batch into a .csv file, then to json, and then load each into a Django database.



      Please let me know how to achieve this task the best way.










      share|improve this question















      My plan is to collect lawyer biography data from websites in batches and convert each batch into a .csv file, then to json, and then load each into a Django database.



      Please let me know how to achieve this task the best way.







      python django json csv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 at 17:54









      alex

      2,46053166




      2,46053166










      asked Dec 10 '09 at 22:58









      Zeynel

      4,5542076127




      4,5542076127
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          Just load the database directly. Collect data from websites in batches, loading the SQlite3 directly. Just write simple batch applications that use the Django ORM. Collect data from websites and load SQLite3 immediately. Do not create CSV. Do not create JSON. Do not create intermediate results. Do not do any extra work.





          Edit.



          from myapp.models import MyModel
          import urllib2

          with open("sourceListOfURLs.txt", "r" ) as source:
          for aLine in source:
          for this, the, the_other in someGenerator( aLine ):
          object= MyModel.objects.create( field1=this, field2=that, field3=the_other )
          object.save()

          def someGenerator( url ):
          # open the URL with urllib2
          # parse the data with BeautifulSoup
          yield this, that, the_other





          share|improve this answer























          • Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
            – Zeynel
            Dec 12 '09 at 16:30










          • What do you mean by "load the SQLite3 directly?"
            – Zeynel
            Dec 12 '09 at 19:48










          • @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
            – S.Lott
            Dec 13 '09 at 14:23











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1884694%2fhow-to-populate-a-django-sqlite3-database%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          Just load the database directly. Collect data from websites in batches, loading the SQlite3 directly. Just write simple batch applications that use the Django ORM. Collect data from websites and load SQLite3 immediately. Do not create CSV. Do not create JSON. Do not create intermediate results. Do not do any extra work.





          Edit.



          from myapp.models import MyModel
          import urllib2

          with open("sourceListOfURLs.txt", "r" ) as source:
          for aLine in source:
          for this, the, the_other in someGenerator( aLine ):
          object= MyModel.objects.create( field1=this, field2=that, field3=the_other )
          object.save()

          def someGenerator( url ):
          # open the URL with urllib2
          # parse the data with BeautifulSoup
          yield this, that, the_other





          share|improve this answer























          • Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
            – Zeynel
            Dec 12 '09 at 16:30










          • What do you mean by "load the SQLite3 directly?"
            – Zeynel
            Dec 12 '09 at 19:48










          • @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
            – S.Lott
            Dec 13 '09 at 14:23















          up vote
          6
          down vote



          accepted










          Just load the database directly. Collect data from websites in batches, loading the SQlite3 directly. Just write simple batch applications that use the Django ORM. Collect data from websites and load SQLite3 immediately. Do not create CSV. Do not create JSON. Do not create intermediate results. Do not do any extra work.





          Edit.



          from myapp.models import MyModel
          import urllib2

          with open("sourceListOfURLs.txt", "r" ) as source:
          for aLine in source:
          for this, the, the_other in someGenerator( aLine ):
          object= MyModel.objects.create( field1=this, field2=that, field3=the_other )
          object.save()

          def someGenerator( url ):
          # open the URL with urllib2
          # parse the data with BeautifulSoup
          yield this, that, the_other





          share|improve this answer























          • Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
            – Zeynel
            Dec 12 '09 at 16:30










          • What do you mean by "load the SQLite3 directly?"
            – Zeynel
            Dec 12 '09 at 19:48










          • @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
            – S.Lott
            Dec 13 '09 at 14:23













          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          Just load the database directly. Collect data from websites in batches, loading the SQlite3 directly. Just write simple batch applications that use the Django ORM. Collect data from websites and load SQLite3 immediately. Do not create CSV. Do not create JSON. Do not create intermediate results. Do not do any extra work.





          Edit.



          from myapp.models import MyModel
          import urllib2

          with open("sourceListOfURLs.txt", "r" ) as source:
          for aLine in source:
          for this, the, the_other in someGenerator( aLine ):
          object= MyModel.objects.create( field1=this, field2=that, field3=the_other )
          object.save()

          def someGenerator( url ):
          # open the URL with urllib2
          # parse the data with BeautifulSoup
          yield this, that, the_other





          share|improve this answer














          Just load the database directly. Collect data from websites in batches, loading the SQlite3 directly. Just write simple batch applications that use the Django ORM. Collect data from websites and load SQLite3 immediately. Do not create CSV. Do not create JSON. Do not create intermediate results. Do not do any extra work.





          Edit.



          from myapp.models import MyModel
          import urllib2

          with open("sourceListOfURLs.txt", "r" ) as source:
          for aLine in source:
          for this, the, the_other in someGenerator( aLine ):
          object= MyModel.objects.create( field1=this, field2=that, field3=the_other )
          object.save()

          def someGenerator( url ):
          # open the URL with urllib2
          # parse the data with BeautifulSoup
          yield this, that, the_other






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 13 '09 at 14:22

























          answered Dec 11 '09 at 2:11









          S.Lott

          314k66437716




          314k66437716












          • Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
            – Zeynel
            Dec 12 '09 at 16:30










          • What do you mean by "load the SQLite3 directly?"
            – Zeynel
            Dec 12 '09 at 19:48










          • @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
            – S.Lott
            Dec 13 '09 at 14:23


















          • Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
            – Zeynel
            Dec 12 '09 at 16:30










          • What do you mean by "load the SQLite3 directly?"
            – Zeynel
            Dec 12 '09 at 19:48










          • @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
            – S.Lott
            Dec 13 '09 at 14:23
















          Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
          – Zeynel
          Dec 12 '09 at 16:30




          Thank you. This sounds good. But can you give me some more detail to start from. A search for "Django ORM" did not lead to any basic stuff that I can use.
          – Zeynel
          Dec 12 '09 at 16:30












          What do you mean by "load the SQLite3 directly?"
          – Zeynel
          Dec 12 '09 at 19:48




          What do you mean by "load the SQLite3 directly?"
          – Zeynel
          Dec 12 '09 at 19:48












          @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
          – S.Lott
          Dec 13 '09 at 14:23




          @Zeynel: Your question says you're using Django. Are you actually using Django? If you are, then you already know about the Django ORM. stackoverflow.com/questions/1884694/… If you're not actually using Django, please update the question to say what you are using.
          – S.Lott
          Dec 13 '09 at 14:23


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1884694%2fhow-to-populate-a-django-sqlite3-database%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?