How to populate a Django sqlite3 database
up vote
1
down vote
favorite
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
add a comment |
up vote
1
down vote
favorite
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
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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
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
python django json csv
edited Nov 15 at 17:54
alex
2,46053166
2,46053166
asked Dec 10 '09 at 22:58
Zeynel
4,5542076127
4,5542076127
add a comment |
add a comment |
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
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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