cities_light don't have all the cities in my country? DJANGO - python

I would like to know how to load all the data in cities_light of Django, I have 42 record when I run python manage.py cities_light --force-import-all or python manage.py cities_light
in settings
CITIES_LIGHT_TRANSLATION_LANGUAGES = ['es']
CITIES_LIGHT_INCLUDE_COUNTRIES = ['CR']
This return 42 records in /cities but I need more than 100
I would like to know how charge more records in the database becouse I have so much code to change if I change cities_light for another library.
I thought that I could make a script for charge the rest of the records for instance a csv, but I need the obligatory fields in the database.
Thanks so much for your help.

Cities Light uses the open Geonames database. So it only knows the cities that are in the Geonames database. You can help and add missing cities there or fix the data on existing entries.
Also, there are different data files for cities from Geonames.
cities1000.zip has all cities with a population >1000
cities5000.zip all cities with a population >5000
cities15000.zip all cities with a population >15000
So maybe you are importing the smallest file that includes only larger towns and cities.

Try to use the http://download.geonames.org/export/dump/[Country_Code].zip
It's the only way I found to load more cities.
You may need to update the CITIES_LIGHT_INCLUDE_CITY_TYPES variable see
http://www.geonames.org/export/codes.html.
I Hope that this will help someone because it took me sometime to figure all this out

Related

Any idea to create the price table which associate with date in Django(Python)

I would like to create a price table by date, I tried to google this for python and django, but still have no idea for this. I don't want to create one to one relationship object like an options. but I would like to create the database associating date and price. Sorry that it may be simple question..
Would it be solution to create a database by using PostgreSQL, and read by django? or any resource / reference can help get me in right direction to access this problem?
Thanks so much
Well there is more to it then assigning a price to a date. You will need one or more tables that hold the establishment(hotels) data. These would include the room information as all rooms will not have the same price. Also the price will probably change over time, so you will need to track that. Then there is the reservation information to track. This is just some of the basics. It is not a simple task by any means. I would try a simpler project to start with to learn Django and how to get data in and out of it.

Inserting two lists into sqllite db

Working on a GUI app with Tkinter and I've collected information via a form into two lists. There is a reason behind why two lists, although there might be a better way.
So now I've got two lists, both contain data I need to enter into my database and each data point is a new row. For example, my gui is an equipment signout program.
So here is an example:
equipmentIdList = [123, 4568, 9876]
Note: equipmentIdList is simply barcodes ids identifying the data in my db
assignedToList = [rob, chris, mike]
So barcode for equipment 123 is assigned to rob and is going into the database to mark it as being checked out. Same for chris and mike.
So where I'm at is how to get this into my database. I did try going to a dictionary but that doesn't seem to really solve my problem either.
Thanks in advance.
You may save your data in a table with 2 columns: person and equipment
(rob, 123)
(chris, 4568)
(mike, 9876)
First you should design and create your table in sqlite, then read document how to generate insert query into your database.

Update logic for data integration

I really need help in finding logic for my script for updating :(
I have a SQL Server database with customer data with ModifiedDate column. And I am moving this data to Odoo using External API with exactly the same columns.
My script will run every day and take the new data from the SQL Server database and add it to Odoo; it has to update those customers which have changed also.
For creating, I am taking max(CreateDate) and using it in the query to take customers after it.
But I am not able to find a good solution for update. Any help?
PS: as data is pretty big, I need to find the fastest solution :( Thanks!
I have found a solution.
I will do one time fetch to the data. And then take today as a parameter and use in the query as:
where ModifiedDate > today
If anybody has a better idea, please share :) Thanks :)

How to convert in OpenERP from one chart of account to another?

I have installed chart of accounts A for company1. This chart was used couple months for accounting. How can I convert into chart of accounts B and keep old data for accounts (debit, credit, etc.)? In other words, is possible migrate data from one chart of accounts to another? Solution could be programmatically or trough web client interface (not important). Virtual charts of accounts can't be used. Chart of accounts B must became main chart with old data.
Every advice will help me a lot. Thanks
I don't know of any way to install another chart of accounts after you've run the initial configuration wizard on a new database. However, if all you want to do is change the account numbers, names, and parents to match a different chart of accounts, then you should be able to do that with a bunch of database updates. Either manually edit each account if there aren't too many accounts, or write a SQL or Python script to update all the accounts. To do that, you'll need to map each old account to a new account code, name, and parent, then use that map to generate a script.
IMO its very difficult we are currently migrating some data and its proving to be difficult.
I would advice you to pick a date in the future and tell everyone to just use another db with the correct chart of accounts.
Your finance dept will be the one to suggest what date is perfect. How about when a period starts.
I needed to do similar. It is possible to massage the chart from one form to another but I found in the end that creating a New Database, bringing in modules, assigning the new Chart and then importing all critical elements was the best and safest path.
If you have a lot of transactions that will be more difficult to do the import on. If that is the case, then massage your chart from one form to another.
I am sure there will be some way to do an active Migration sometime in the future. You defintely don't want to live with a bad chart or with out your history if you can help it.
The fastest way to do so is using a ETL like Talend or Pentaho (provided there is a logic as to which account will map to which other during the process). If not you will have to do so by hand.
In case there is a logic, you would export it to a format you can transform and re import. Uninstall your account chart and install the new. Then import all the data that you formatted using those tools.

geo name database (city, points of interest)

I am building a travel website with django. When a user is typing in the destination city name (or points of interest, like yellow stone), I want to do ajax auto suggestion. The question is how I could get the suggestion database? Is there any web service? Best if it could also support foreign cities. Thanks a lot.
What you want is called a gazetteer database.
The official USGS gazetteer for the USA is available for download.
Two global geocoded databases include:
Geonames has a free list of cities and POI. It includes the USGS gazetteer and lots of other info. You might have to subset their database however, as it might return too many results for you.
Maxmind also have a free database of cities.
take a look at OpenStreetMap there are a lot of cities, pois both in chinease and english

Categories

Resources