Minor cleanup.
This commit is contained in:
parent
54bfd924b8
commit
c432d3c6a7
15
README.md
15
README.md
|
|
@ -250,3 +250,18 @@ It would be fun to see if the Treeview widget could handle all the stars
|
|||
and planets... 12,300 planets, 1,948 stars, it should be able to handle
|
||||
it?
|
||||
|
||||
|
||||
Mon Apr 15 15:48:51 PDT 2024
|
||||
|
||||
Pop growth on homeworlds only: we want the populations that are on a
|
||||
planet where that planet is in the home stellar system of the species of
|
||||
the population.
|
||||
|
||||
planets.star = populations.homestar
|
||||
|
||||
What if in the populations table instead of the species column there is a
|
||||
home system column? We can get the species name from the homestar name
|
||||
as needed?
|
||||
|
||||
Is there a good reason not to have the species name with the pops? Extra
|
||||
space used I guess, maybe? pop.homestar.name + 'ians'
|
||||
|
|
|
|||
14
data.py
14
data.py
|
|
@ -62,10 +62,22 @@ TABLES = [
|
|||
species TEXT,
|
||||
pop INTEGER,
|
||||
planet INTEGER,
|
||||
vessel INTEGER,
|
||||
station INTEGER,
|
||||
FOREIGN KEY(planet) REFERENCES planets(id)
|
||||
)''',
|
||||
check (
|
||||
( case when planet is null then 0 else 1 end
|
||||
+ case when vessel is null then 0 else 1 end
|
||||
+ case when station is null then 0 else 1 end
|
||||
) = 1
|
||||
)
|
||||
)
|
||||
''',
|
||||
]
|
||||
|
||||
# Apparently this clause should constrain a pop to be
|
||||
# in only one location at a time.
|
||||
|
||||
|
||||
def initialize_db_tables(filename):
|
||||
conn = open_db(filename)
|
||||
|
|
|
|||
BIN
game.sqlite
BIN
game.sqlite
Binary file not shown.
|
|
@ -52,7 +52,7 @@ def init_db(conn):
|
|||
'insert into populations(species, pop, planet) values (?, ?, ?)',
|
||||
(people_name, INITIAL_POP, planet_id),
|
||||
)
|
||||
print(planet_id, bio, industrial_capacity)
|
||||
# print(planet_id, bio, industrial_capacity)
|
||||
c.close()
|
||||
conn.commit()
|
||||
|
||||
|
|
@ -61,8 +61,8 @@ def get_name_of_planets_star(db_cursor, planet_id):
|
|||
# My first ever JOIN statement! Squeeeee!
|
||||
db_cursor.execute(
|
||||
'''\
|
||||
select stars.name from stars
|
||||
join planets
|
||||
select stars.name from
|
||||
stars join planets
|
||||
on stars.id = planets.star
|
||||
and planets.id = ?
|
||||
''',
|
||||
|
|
|
|||
Loading…
Reference in New Issue