new_tree.py
Dec 26, 2023 0:09:17 GMT -8
Post by Uncle Buddy on Dec 26, 2023 0:09:17 GMT -8
<drive>:\treebard\app\python\new_tree.py Last Changed 2024-03-03
# new_tree.py
import sqlite3
from files import app_path, appwide_db_path, current_drive
import dev_tools as dt
from dev_tools import look, seeline
# The tables in `default_new_tree` are completely blank so we don't have to
# remember which tables have default rows in them. Default values are added,
# edited, and remembered in this module. These functions run every time the
# user creates a new tree, since the default new tree is now completely
# blank. This code is run in `make_tree()` which is in `opening.py`.
# When a table schema is altered while developing in `sample_tree.db`, delete
# `default_new_tree.db` and do this to make a whole new `default_new_tree.db`
# in a few easy steps:
# C:\Users\Lutherman>sqlite3 d:/treebard/data/sample_tree/sample_tree.tbd
# SQLite version 3.34.0 2020-12-01 16:14:00
# sqlite> .output d:/treebard/data/settings/default_new_tree.sql
# sqlite> .schema
# sqlite> .exit
# C:\Users\Lutherman>sqlite3 d:/treebard/data/settings/default_new_tree.db < d:/treebard/data/settings/default_new_tree.sql
# Error: near line 1: object name reserved for internal use: sqlite_sequence
# (I DON'T KNOW what the error is but the import of the schema seems to work fine.)
COLOR_TYPES = [
(1,'#414141','#646464','#878787','#c8c8c8',1,0),
(2,'#061d2f','#284b80','#267d82','#71cfd5',1,0),
(3,'red','blue','magenta','yellow',1,1),
(240,'#232931','#393e46','#2E5447','#eeeeee',1,0),
(241,'#393932','#4d4545','#8d6262','#f1c5c5',1,0),
(242,'#212121','#323232','#0d7377','#7efee1',1,0),
(243,'#423030','#605656','gray','lightgray',1,0),
(244,'#a3e4db','#fed1ef','#72aef7','#333333',1,0),
(245,'#f0ece3','#dfd3c3','#c7b198','#5e5448',1,1),
(246,'#d3e4cd','#f2ddc1','#e2c2b9','#33282d',1,0),
(247,'#fff1af','#b4c6a6','#ab937b','#1c150e',1,0),
(248,'#f3f0d7','#cee5d0','#fed2aa','#1f1913',1,0),
(249,'#c8e3d4','#f6d7a7','#f6eabe','#1a1814',1,0),
(250,'#e5dcc3','#c7bea2','#aaa492','#12110f',1,0),
(251,'#faeee0','#f9e4c8','#d8d0c0','#121110',1,0),
(252,'#f3f0d7','#cee5d0','#e0c097','#1d2226',1,0),
(253,'#f3d5c0','#d4b499','#889eaf','#242426',1,0),
(254,'#ffe3e3','#e4d8dc','#c9ccd5','#21201a',1,0),
(255,'#feffe2','#f0f0cb','#dad5ab','#1c1a17',1,0),
(256,'#f4dfd0','#dad0c2','#cdbba7','#1a1615',1,0),
(257,'#f8e2cf','#f5c6aa','#fcd8d4','#0f1112',1,0),
(258,'#f1ecc3','#c9d8b6','#90a7b0','#171612',1,0),
(259,'#e6ddc6','#c3b8a3','#a19882','#1f181b',1,0),
(260,'#caf7e3','#f6dfeb','#e4bad4','#1c1a16',1,0),
(261,'#f6e6cb','#e3cdc1','#a0937d','#171a16',1,0),
(262,'#f8ede3','#bdd2b6','#798777','#171315',1,0),
(263,'#caf7e3','#f6dfeb','#e4bad4','#141414',1,0),
(264,'#f9f7cf','#f2dcbb','#bbbbbb','#151617',1,0),
(265,'#f4f4f2','#e8e8e8','#bbbfca','#170e11',1,0),
(266,'#d6e5fa','#baabda','#d77fa1','#1a0e12',1,0),
(267,'#7b6079','#506362','#de8971','#e3d8e2',1,1),
(268,'#433520','#025955','#00917c','#fde8cd',1,0),
(269,'#0d335d','#1a508b','#c1a1d3','#fff3e6',1,0),
(270,'#19456b','#11698e','#16c79a','#f8f1f1',1,0),
(271,'#424242','#a98b98','#4e3d53','#a6f0c6',1,0),
(272,'#351f39','#726a95','#485154','#a0c1b8',1,0),
(273,'#222831','#4f8a8b','#615229','#eeeeee',1,0),
(274,'#3e3838','#ae7c7c','#365e5a','#e3dada',1,0),
(275,'#305973','#ef7e56','#787371','#e6dfdc',1,1),
(276,'#041c32','#04293a','#064663','#ced7db',1,0),
(277,'#112031','#152d35','#345b63','#d4ecdd',1,0),
(278,'#334257','#476062','#548ca8','#eeeeee',1,0),
(279,'#351f39','#726a95','#485154','#a0c1b8',1,0),
(280,'#382933','#3b5249','#3d5448','#a4b494',1,0),
(281,'#4d4646','#5b5656','#47544a','#f5eaea',1,0),
(282,'#222831','#393e46','#d65a31','#eeeeee',1,1),
(283,'#33313b','#62374e','#007880','#ccbec5',1,0),
(284,'#33313b','#3c4f65','#834c69','#e6f5ff',1,0),
(285,'#272121','#363333','#e16428','#f6e9e9',1,1),
(286,'#2a2438','#352f44','#5c5470','#dbd8e3',1,0),
(287,'#a0937d','#3a6351','#5f939a','#f2edd7',1,1),
(288,'#35483a','#647d73','#7e6373','#d5e0dc',1,0),
(289,'#35483a','#647d73','#4d444b','#d5e0dc',1,0),
(290,'#34615f','#4a8a87','#486a8c','#b9ddd9',1,0),
(291,'#344140','#5a7270','#977d77','#ffffff',1,0),
(292,'#1e1e1e','#484848','#43523f','#d7d7d7',1,0),
(293,'#b8a089','#cbbaa9','#ded3c9','#2d241c',1,0),
(294,'#0C1021','#55606c','#808c9b','white',1,0),
(295,'#283133','#899ea3','#86a68b','white',1,0),
(296,'#2F343F','#424242','#212121','#AFB9C6',1,0),
(297,'#38555f','#507987','#4d598a','#ced6d9',1,0),
(298,'#151a26','#3d4b6d','#6c8093','#dadee6',1,0),
(299,'#152028','#232b32','#202945','#d8dee3',1,0),
(300,'#121212','#606782','#34393b','#99b0bb',1,0),
(301,'#121212','#403250','#34383d','#d9d5de',1,0),
(302,'#dbdde8','#b4b8cf','#8087ae','#1c1c21',1,0),
(303,'#bcd0d3','#97b7bb','#639196','#141b1c',1,0),
(314,'#f0ece3','#dfd3c3','#c7b198','#363636',0,0),
(315,'#a0937d','#3a6351','#5f939a','#f3f3f3',0,0),
(317,'#34615f','#4a8a87','#486a8c','#faeefb',0,0),
(318,'#c8e3d5','#f6d7a8','#f6eabf','#1a1815',0,0)]
EVENT_TYPES = [
(1,'birth',1,0,0,0,0),
(2,'marriage',1,0,1,0,1),
(3,'illness',1,0,0,0,0),
(4,'death',1,0,0,0,0),
(5,'burial',1,0,0,1,0),
(6,'occupation',1,0,0,0,0),
(7,'imprisonment',1,0,0,0,0),
(8,'deportation',1,0,0,0,0),
(9,'invention',1,0,0,0,0),
(10,"religious conversion",1,0,0,0,0),
(11,'wedding',1,0,1,0,1),
(12,"ran away from home",1,0,0,0,0),
(13,'residence',1,0,0,0,0),
(14,'autopsy',1,0,0,1,0),
(15,'divorce',1,0,1,0,1),
(16,'engagement',1,0,1,0,0),
(17,'annulment',1,0,1,0,1),
(18,'separation',1,0,1,0,1),
(19,"eye color",1,0,0,0,0),
(20,"hair color",1,0,0,0,0),
(21,'height',1,0,0,0,0),
(22,'weight',1,0,0,0,0),
(23,'build',1,0,0,0,0),
(24,'complexion',1,0,0,0,0),
(25,'race',1,0,0,0,0),
(26,"ethnic origin",1,0,0,0,0),
(27,"marks, scars",1,0,0,0,0),
(28,'disability',1,0,0,0,0),
(29,'condition',1,0,0,0,0),
(30,'religion',1,0,0,0,0),
(31,'career',1,0,0,0,0),
(32,"number of children, total",1,0,0,0,0),
(33,"number of children, living",1,0,0,0,0),
(34,"marital status",1,0,0,0,0),
(35,"political affiliation",1,0,0,0,0),
(36,"special talent",1,0,0,0,0),
(37,'hobby',1,0,0,0,0),
(38,"able to read",1,0,0,0,0),
(39,"able to write",1,0,0,0,0),
(40,"first language",1,0,0,0,0),
(41,'nationality',1,0,0,0,0),
(42,"education level",1,0,0,0,0),
(43,"draft registration",1,0,0,0,0),
(44,"legal problem",1,0,0,0,0),
(45,"tobacco use",1,0,0,0,0),
(46,"alcohol use",1,0,0,0,0),
(47,"drug problem",1,0,0,0,0),
(48,'guardianship',1,0,0,0,0),
(49,'inquest',1,0,0,1,0),
(50,'relationship',1,0,1,0,0),
(51,"bar mitzvah",1,0,0,0,0),
(52,"bas mitzvah",1,0,0,0,0),
(53,"jury duty",1,0,0,0,0),
(54,'baptism',1,0,0,0,0),
(55,'excommunication',1,0,0,0,0),
(56,'betrothal',1,0,1,0,0),
(57,'resignation',1,0,0,0,0),
(58,'naturalization',1,0,0,0,0),
(59,"marriage license",1,0,1,0,1),
(60,'christening',1,0,0,0,0),
(61,'confirmation',1,0,0,0,0),
(62,'cremation',1,0,0,1,0),
(63,'will',1,0,0,0,0),
(64,'retirement',1,0,0,0,0),
(65,'ordination',1,0,0,0,0),
(66,'graduation',1,0,0,0,0),
(67,'emigration',1,0,0,0,0),
(68,'probate',1,0,0,1,0),
(69,'enrollment',1,0,0,0,0),
(70,'execution',1,0,0,0,0),
(71,'employment',1,0,0,0,0),
(72,"land grant",1,0,0,0,0),
(73,"name change",1,0,0,0,0),
(74,"land purchase",1,0,0,0,0),
(75,"land sale",1,0,0,0,0),
(76,"military induction",1,0,0,0,0),
(77,"military enlistment",1,0,0,0,0),
(78,"military discharge",1,0,0,0,0),
(79,"military promotion",1,0,0,0,0),
(80,"military service",1,0,0,0,0),
(81,"marriage banns",1,0,1,0,0),
(82,"missing in action",1,0,0,0,0),
(83,'adoption',1,0,0,0,0),
(84,'reburial',1,0,0,1,0),
(85,"filing for divorce",1,0,1,0,1),
(86,"reading of the will",1,0,0,1,0),
(87,'exhumation',1,0,0,1,0),
(88,'funeral',1,0,0,1,0),
(89,"celebration of life",1,0,0,1,0),
(90,'partnership',1,0,1,0,1),
(91,"natural disaster",1,0,0,0,0),
(92,'blessing',1,0,0,0,0),
(93,"anniversary celebration",1,0,1,0,1),
(94,"first communion",1,0,0,0,0),
(95,'fosterage',1,0,0,0,0),
(96,"posthumous offspring",1,0,0,1,0),
(97,'immigration',1,0,0,0,0),
(98,"marriage contract",1,0,1,0,1),
(99,'reunion',1,0,0,0,0),
(100,"scattering of ashes",1,0,0,1,0),
(101,'inurnment',1,0,0,1,0),
(102,'cohabitation',1,0,1,0,1),
(103,"living together",1,0,1,0,1),
(104,"wedding anniversary",1,0,1,0,1),
(105,"patent filing",1,0,0,0,0),
(106,"patent granted",1,0,0,0,0),
(107,'interment',1,0,0,0,0),
(108,'learning',1,0,0,0,0),
(109,'conversion',1,0,0,0,0),
(110,'travel',1,0,0,0,0),
(111,'caste',1,0,0,0,0),
(112,'description',1,0,0,0,0),
(113,"number of marriages",1,0,0,0,0),
(114,'property',1,0,0,0,0),
(115,'imaginary',1,0,0,0,0),
(116,"marriage settlement",1,0,1,0,1),
(117,"unknown event type",1,0,0,0,0),
(118,'education',1,0,0,0,0),
(119,'specialty',0,0,0,0,0),
(120,'award',0,0,0,0,0)]
NAME_TYPES = [
(1,"birth name",0,1,0),
(2,"also known as",3,1,0),
(3,'pseudonym',6,1,0),
(4,"ID number",18,1,0),
(5,"adoptive name",2,1,0),
(6,"married name",4,1,0),
(7,'handle',19,1,0),
(8,"alternate spelling",16,1,0),
(9,'mis-spelling',17,1,0),
(10,"legally changed name",5,1,0),
(11,"stage name",8,1,0),
(12,'nickname',9,1,0),
(13,"call name",10,1,0),
(14,"official name",13,1,0),
(15,"anglicized name",14,1,0),
(16,"unknown name",24,1,0),
(17,"religious order name",15,1,0),
(18,"other name type",21,1,0),
(19,"code name",20,1,0),
(20,"pen name",7,1,0),
(21,"given name",23,1,0),
(22,"reference name",1,1,0),
(23,'surname',22,1,0),
(24,"name at work",25,1,0),
(25,"placeholder for name",26,1,0),
(26,"immigrant name",11,1,0),
(27,'title',12,1,0),
(28,"name prefix",99,1,0),
(29,"name suffix",99,1,0),
(30,"surname prefix",99,1,0),
(31,"usual name",99,1,0),
(32,"social security number",99,1,0),
(33,"permit number",999,1,0),
(34,"forum handle",999,1,0)]
SOURCE_TYPES = [
(1,'newspaper',1,0),
(2,"technical journal",1,0),
(3,'magazine',1,0),
(4,"genealogy newsletter",1,0),
(5,'blog',1,0),
(6,"baptism record",1,0),
(7,"bible record",1,0),
(8,"birth certificate",1,0),
(9,"birth register",1,0),
(10,'book',1,0),
(11,"grave marker",1,0),
(12,'census',1,0),
(13,"church record",1,0),
(14,"death certificate",1,0),
(15,'yearbook',1,0),
(16,"directory (organization)",1,0),
(17,"directory (church)",1,0),
(18,"directory (city etc.)",1,0),
(19,"directory (telephone)",1,0),
(20,'deed',1,0),
(21,"land patent",1,0),
(22,"patent (invention)",1,0),
(23,'diary',1,0),
(24,"email message",1,0),
(25,'interview',1,0),
(26,"personal knowledge",1,0),
(27,"family story",1,0),
(28,"audio record",1,0),
(29,"video record",1,0),
(30,"letter or postcard",1,0),
(31,"probate record",1,0),
(32,'will',1,0),
(33,"legal proceedings record",1,0),
(34,'manuscript',1,0),
(35,'map',1,0),
(36,"marriage certificate",1,0),
(37,"marriage license",1,0),
(38,"marriage register (county etc.)",1,0),
(39,"marriage record (church)",1,0),
(40,"naturalization file",1,0),
(41,'obituary',1,0),
(42,"pension file",1,0),
(43,'photograph',1,0),
(44,"painting or drawing",1,0),
(45,"passenger list",1,0),
(46,"tax roll",1,0),
(47,"death index",1,0),
(48,"birth index",1,0),
(49,"town record",1,0),
(50,'transcription',1,0),
(51,"web page",1,0),
(52,"military record",1,0),
(53,"draft registration",1,0),
(54,"enlistment record",1,0),
(55,"muster roll",1,0),
(56,"burial record",1,0),
(57,"cemetery record",1,0),
(58,"death notice",1,0),
(59,"marriage index",1,0),
(60,"secondary source",1,0),
(61,"alumni publication",1,0),
(62,"parish record",1,0),
(63,'passport',1,0),
(64,"passport application",1,0),
(65,"identification card",1,0),
(66,"immigration record",1,0),
(67,"border crossing record",1,0),
(68,"funeral home records",1,0),
(69,'theory',1,0),
(70,'guess',1,0),
(71,'hunch',1,0),
(72,'hypothesis',1,0),
(73,"article (clipping; source unknown)",1,0),
(74,'newsletter',1,0),
(75,'directory',1,0),
(76,'brochure',1,0),
(77,'pamphlet',1,0),
(78,'poster',1,0),
(79,'jewelry',1,0),
(80,"church service bulletin",1,0),
(81,'advertisement',1,0),
(82,'cemetery',1,0),
(83,"application for social security card form SS5 (USA)",1,0),
(84,'contact',1,0),
(85,"prison records",1,0),
(86,"arrest record",1,0),
(87,'researcher',1,0)]
PLACE_TYPES = [
(1,'nation','',1,0),
(2,'province','',1,0),
(3,'state','',1,0),
(4,'county','',1,0),
(5,'city','',1,0),
(6,'township','',1,0),
(7,'parish','',1,0),
(8,'island','',1,0),
(9,'archipelago','',1,0),
(10,'continent','',1,0),
(11,"unincorporated town",'',1,0),
(12,'barangay','',1,0),
(13,'purok','',1,0),
(14,"Indian country",'',1,0),
(15,'colony','',1,0),
(16,'settlement','',1,0),
(17,'village','',1,0),
(18,'empire','',1,0),
(19,'address','',1,0)]
ROLE_TYPES = [
(1,"religious officer",1,0),
(2,"justice of the peace",1,0),
(3,"arresting officer",1,0),
(4,'supervisor',1,0),
(5,'employer',1,0),
(6,'midwife',1,0),
(7,'bridesmaid',1,0),
(8,"best man",1,0),
(9,"bible bearer",1,0),
(10,"flower girl",1,0),
(11,'witness',1,0),
(12,'employee',1,0),
(13,'assistant',1,0),
(14,'roommate',1,0),
(15,'landlady',1,0),
(16,'landlord',1,0),
(17,'unknown',1,0),
(18,"foster parent",1,0),
(19,"makeup artist",1,0),
(20,'financier',1,0),
(21,'florist',1,0),
(22,'usher',1,0),
(23,'photographer',1,0),
(24,'bartender',1,0),
(25,'bodyguard',1,0),
(26,"adoptive parent",1,0),
(27,'hairdresser',1,0),
(28,'chauffeur',1,0),
(29,'treasurer',1,0),
(30,'trainer',1,0),
(31,'secretary',1,0),
(32,'navigator',1,0),
(33,'pallbearer',1,0),
(39,'neighbor',1,0),
(40,'maid',1,0),
(41,'pilot',1,0),
(43,'undertaker',1,0),
(44,"mining partner",1,0),
(47,"legal guardian",1,0),
(55,'other',1,0),
(87,"interior decorator",1,0),
(88,'executioner',1,0),
(90,'driver',1,0),
(96,'host',1,0),
(97,'hostess',1,0),
(99,"farm hand",1,0),
(100,"ranch hand",1,0),
(103,"junior partner",1,0),
(114,'butler',1,0),
(115,'boarder',1,0),
(116,'chef',1,0),
(117,"patent attorney",1,0)]
REPOSITORY_TYPES = [
(1,"public library",1,0),
(2,"college library",1,0),
(3,"national library",1,0),
(4,"national archives",1,0),
(5,'website',1,0),
(6,"personal collection",1,0),
(7,"cemetery or mausoleum",1,0),
(8,'museum',1,0),
(9,"state library",1,0),
(10,"church library",1,0),
(11,"genealogy society collection",1,0),
(12,'library',1,0),
(13,"government agency",1,0),
(14,"funeral home",1,0),
(15,"private library",1,0),
(16,"national bibliography",1,0),
(17,"collective unconscious, the",1,0),
(18,"historical society collection",1,0),
(19,"prison library",1,0),
(20,"trunk in the attic",1,0)]
TRANSCRIPTION_TYPES = [
(1,"International Phonetic Alphabet (API)",0,1,1,0),
(2,'Wade-Giles',1,0,1,0),
(3,"Hanyu Pinyin (Pinyin)",1,0,1,0),
(4,"Wapuro romaji (romaji)",1,0,1,0),
(5,'hangul',0,1,1,0),
(6,'kana',0,1,1,0),
(7,'IPA',0,1,1,0),
(8,"Traditional IPA",0,1,1,0),
(9,"Modern IPA",0,1,1,0)]
KIN_TYPES = [
(1,'mother','mother',1,0),
(2,'father','father',1,0),
(3,'parent','parent',1,0),
(4,'son','son',1,0),
(5,'daughter','daughter',1,0),
(6,'child','child',1,0),
(7,'sister','sister',1,0),
(8,'brother','brother',1,0),
(9,'sibling','sibling',1,0),
(10,'husband','husband',1,0),
(11,'wife','wife',1,0),
(12,'spouse','spouse',1,0),
(13,'partner','partner',1,0),
(14,"son of sibling of father",'cousin',1,0),
(15,"son of sibling of mother",'cousin',1,0),
(16,"daughter of sibling of father",'cousin',1,0),
(17,"daughter of sibling of mother",'cousin',1,0),
(18,"father of father",'grandfather',1,0),
(19,"mother of father",'grandmother',1,0),
(20,"father of mother",'grandfather',1,0),
(21,"mother of mother",'grandmother',1,0),
(22,"parent of father",'grandparent',1,0),
(23,"parent of mother",'grandparent',1,0),
(24,"son of son",'grandson',1,0),
(25,"son of daughter",'grandson',1,0),
(26,"daughter of son",'granddaughter',1,0),
(27,"daughter of daughter",'granddaughter',1,0),
(28,"sister of mother",'aunt',1,0),
(29,"sister of father",'aunt',1,0),
(30,"brother of father",'uncle',1,0),
(31,"brother of mother",'uncle',1,0),
(32,"daughter of sister of mother",'niece',1,0),
(33,"daughter of brother of mother",'niece',1,0),
(34,"daughter of sister of father",'niece',1,0),
(35,"daughter of brother of father",'niece',1,0),
(36,"son of sister of mother",'nephew',1,0),
(37,"son of brother of mother",'nephew',1,0),
(38,"son of sister of father",'nephew',1,0),
(39,"son of brother of father",'nephew',1,0),
(40,"father of father of father",'great-grandfather',1,0),
(41,"father of mother of father",'great-grandfather',1,0),
(42,"father of father of mother",'great-grandfather',1,0),
(43,"father of mother of mother",'great-grandfather',1,0),
(44,"mother of father of father",'great-grandmother',1,0),
(45,"mother of mother of father",'great-grandmother',1,0),
(46,"mother of father of mother",'great-grandmother',1,0),
(47,"mother of mother of mother",'great-grandmother',1,0),
(48,"brother of father of father",'great-uncle',1,0),
(49,"sister of mother of father",'great-aunt',1,0),
(50,"brother of father of mother",'great-uncle',1,0),
(51,"sister of mother of mother",'great-aunt',1,0),
(52,"father of spouse",'father-in-law',1,0),
(53,"mother of spouse",'mother-in-law',1,0),
(54,"brother of spouse",'brother-in-law',1,0),
(55,"husband of sibling",'brother-in-law',1,0),
(56,"husband of brother of spouse",'brother-in-law',1,0),
(57,"husband of sister of spouse",'brother-in-law',1,0),
(58,"sister of spouse",'sister-in-law',1,0),
(59,"wife of sibling",'sister-in-law',1,0),
(60,"wife of brother of spouse",'brother-in-law',1,0),
(61,"wife of sister of spouse",'brother-in-law',1,0),
(62,"husband of child",'son-in-law',1,0),
(63,"wife of child",'daughter-in-law',1,0)]
LOCATOR_TYPES = [
(1,"Dewey Decimal Classification",1,0,'DDC'),
(2,"Library of Congress Classification",1,0,'LCC'),
(3,"web page, Uniform Resource Locator",1,0,'URL'),
(4,"International Standard Book Number",1,0,'ISBN'),
(5,"FHL Digital Folder Number",1,0,'DGS'),
(6,"FHL Microfilm/Microfiche Number",1,0,'GS'),
(7,"Garside Classification Scheme",1,0,''),
(8,"Universal Decimal Classification",1,0,'UDC'),
(9,"Colon Classification",1,0,'CC'),
(10,"index card number",1,0,''),
(11,"FHL Ancestral File Number",1,0,'AFN'),
(12,"reference number",1,0,'REFN')]
MEDIA_TYPES = [
(1,'image',1,0),
(2,'audio',1,0),
(3,'video',1,0),
(4,'home movie',1,0),
(5,'newsreel',1,0),
(6,'microfilm',1,0),
(7,'microfiche',1,0),
(8,'cd-rom',1,0)]
def populate_tables(database_file):
""" Run this in files.py new tree function. """
conn = sqlite3.connect(database_file)
cur = conn.cursor()
insert_types_values(cur, conn)
insert_settings(cur, conn)
insert_default_values(cur, conn)
cur.close()
conn.close()
def insert_settings(cur, conn):
cur.execute("INSERT INTO current (current_id, nested_place_id, person_id) VALUES (1, 1, 1)")
conn.commit()
cur.execute(
'''
INSERT INTO date_format (
date_format_id, date_formats, abt, est, cal, bef_aft, bc_ad, os_ns, span, range)
VALUES (1,'dmy','abt','est','cal','bef/aft','BCE/CE','OS/NS','from_to','btwn_&')
''')
conn.commit()
cur.execute(
'''
INSERT INTO font_preference (
format_id, output_font, input_font, font_size, default_output_font,
default_input_font, default_font_size)
VALUES (1, 'courier', "dejavu sans mono", 12, 'courier', "dejavu sans mono", 12)
''')
conn.commit()
cur.execute("INSERT INTO preferences (preferences_id, use_default_images) VALUES (1, 1)")
conn.commit()
def insert_default_values(cur, conn):
""" Treebard uses a default person which can be changed into a real person
with a real name etc., and a default unknown place which can't be
changed but is not seen by the user.
"""
cur.execute("INSERT INTO person (person_id, gender) VALUES (1, 'unknown')")
conn.commit()
cur.execute(
'''
INSERT INTO place (
place_id, latitude, longitude, cartesian_coordinates, township,
range, section, legal_subdivision, hint, check_dupes)
VALUES (1, '', '', '', '', '', '', '', null, 1)
''')
conn.commit()
cur.execute(
'''
INSERT INTO place_name (
place_name_id, place_names, place_id, main_place_name)
VALUES (1, 'unknown', 1, 1)
''')
conn.commit()
cur.execute(
'''
INSERT INTO nested_place (
nested_place_id, nest0, nest1, nest2, nest3, nest4, nest5,
nest6, nest7, nest8)
VALUES (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
''')
conn.commit()
cur.execute(
'''
INSERT INTO event (
event_id, date, particulars, age, person_id, event_type_id,
date_sorter, nested_place_id, age1, age2, couple_id)
VALUES (1, "-0000-00-00-------", "", 0, 1, 1, "0,0,0", 1, "", "", null)
''')
conn.commit()
cur.execute("SELECT name_type_id FROM name_type WHERE name_types = 'placeholder for name'")
name_type_id = cur.fetchone()[0]
cur.execute(
'''
INSERT INTO name (
name_id, person_id, names, name_type_id, sort_order, used_by)
VALUES (
1, 1, "Default person #1", ?, "default person #1", "")
''',
(name_type_id,))
conn.commit()
def insert_types_values(cur, conn):
cur.executemany(
'''
INSERT INTO colors_type (
colors_type_id, color1, color2, color3, color4, built_in, hidden)
VALUES (?, ?, ?, ?, ?, ?, ?)
''',
COLOR_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO event_type (
event_type_id, event_types, built_in, hidden, couple, after_death, marital)
VALUES (?, ?, ?, ?, ?, ?, ?)
''',
EVENT_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO kin_type (
kin_type_id, kin_types, abbrev_kin_types, built_in, hidden)
VALUES (?, ?, ?, ?, ?)
''',
KIN_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO locator_type (
locator_type_id, locator_types, built_in, hidden, abbreviation)
VALUES (?, ?, ?, ?, ?)
''',
LOCATOR_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO media_type (
media_type_id, media_types, built_in, hidden)
VALUES (?, ?, ?, ?)
''',
MEDIA_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO name_type (
name_type_id, name_types, hierarchy, built_in, hidden)
VALUES (?, ?, ?, ?, ?)
''',
NAME_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO place_type (
place_type_id, place_types, description, built_in, hidden)
VALUES (?, ?, ?, ?, ?)
''',
PLACE_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO repository_type (
repository_type_id, repository_types, built_in, hidden)
VALUES (?, ?, ?, ?)
''',
REPOSITORY_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO role_type (
role_type_id, role_types, built_in, hidden)
VALUES (?, ?, ?, ?)
''',
ROLE_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO source_type (
source_type_id, source_types, built_in, hidden)
VALUES (?, ?, ?, ?)
''',
SOURCE_TYPES)
conn.commit()
cur.executemany(
'''
INSERT INTO transcription_type (
transcription_type_id, transcription_types, romanized, phonetic, built_in, hidden)
VALUES (?, ?, ?, ?, ?, ?)
''',
TRANSCRIPTION_TYPES)
conn.commit()