Welcome to the Family Echo Q&A forum. In order to ask or answer questions, please ensure you sign in at Family Echo first.
Welcome to Family Echo Q&A. In order to ask or answer questions, please ensure you sign in at Family Echo first.

Before asking a question, please check the Frequently Asked Questions page.

June 25, 2026: This Q&A has just been moved to a new server. If you experience any problems, please let us know.
0 votes
457 views
import sqlite3

import gedcom

conn = sqlite3.connect('F.db')
c = conn.cursor()
#make sure that family.db is in utf-8 encoding
c.execute("PRAGMA encoding = 'UTF-8';")

def deleteTableContent(tableName):
    #delete all rows in table
    c.execute(f"DELETE FROM {tableName};")
    #reset autoincrement


deleteTableContent("Families")
deleteTableContent("Individuals")
c.execute('''CREATE TABLE IF NOT EXISTS Individuals 
                (ID INTEGER PRIMARY KEY,SURNAME VARCHAR(255),GIVENNAME VARCHAR(255))''')
# Create table if it does not exist


c.execute('''CREATE TABLE IF NOT EXISTS Families
                (ID INTEGER PRIMARY KEY,HUSBAND INTEGER,WIFE INTEGER,Child INTEGER)''')



#insert data into the table
c.execute("INSERT INTO Individuals VALUES (1,'James','Smith')")
c.execute("INSERT INTO Individuals VALUES (2,'Jack','Smith')")
c.execute("INSERT INTO Individuals VALUES (3,'John','Smith')")
c.execute("INSERT INTO Individuals VALUES (4,'Jane','Smith')")
c.execute("INSERT INTO Individuals VALUES (5,'Jill','Smith')")

c.execute("INSERT INTO Families VALUES (1,1,2,3)")
c.execute("INSERT INTO Families VALUES (2,3,4,5)")


#commit the changes
# conn.commit()

#get the data from the table
Individuals = c.execute("SELECT * FROM Individuals")
Individuals = Individuals.fetchall()
Families = c.execute("SELECT * FROM Families")
Families = Families.fetchall()


print(Individuals,Families)




conn.close()


with open('F.ged','w') as Gedcomfile:
    for person in Individuals:
        Gedcomfile.write(f"""
        0 @I{person[0]}@ INDI
        1 NAME {person[1]} /{person[2]}/
        2 GIVN {person[1]} 
        2 SURN {person[2]}
        """)
    for family in Families:
        Gedcomfile.write(f"""
        0 @F{family[0]}@ FAM
        1 HUSB @I{family[1]}@
        1 WIFE @I{family[2]}@
        1 CHIL @I{family[3]}@
        """)

I have this python code that generates a .ged file but when I put it into https://familyecho.com/ is doesn't work pls help.

by Flow_Glow (150 points)
What is the output of your python program?

Please log in or register to answer this question.

...