Table_to_merge = input("Table to Merge: ")Ĭursor_a.execute("CREATE TABLE IF NOT EXISTS " new_table_name " AS SELECT * FROM " table_name)įor row in cursor_b.execute("SELECT * FROM " table_name):Ĭursor_a.execute("INSERT INTO " new_table_name " VALUES" str(row) " ")Ĭursor_a.execute("DROP TABLE IF EXISTS " table_name) Ĭursor_a.execute("ALTER TABLE " new_table_name " RENAME TO " table_name) Ĭursor_a. ros2 bag info mybag1/ Files: mybag10.db3 Bag size: 16. Go to the folder where the bags are saved, and use ros2 bag info name of the folder (name of the bag). """Basic python script to merge data of 2 !!!IDENTICAL!!!! SQL tables"""Ĭursor_a.execute("SELECT name FROM sqlite_master WHERE type='table' ") You don’t need to worry about what’s inside the folders (metadata.yaml and SQLite3 files), the ros2 bag info command gives you all the info you need. Late answer, but you can use: #!/usr/bin/python db text inside: SQLite format 3 I am currently getting 785 results. For example, on my Win10 PC if I search in 'c:\Users\Konstantin' (my profile) for files with: file name mask. import sqlite3Ĭon3.execute("ATTACH '" db2 "' as dba")įor row in con3.execute("SELECT * FROM dba.sqlite_master WHERE type='table'"):Ĭombine = "INSERT OR IGNORE INTO " row " SELECT * FROM dba." rowįor root,d_names,f_names in os.walk(directory):įilename, file_extension = os.path.splitext(c_name)īatch_merge('/directory/to/database/files') SQLite is whidely used by many applications so I am pretty sure very lot examples can be found on your computer. Here is a simple python code to either merge two database files or scan a directory to find all database files and merge them all together (by simply inserting all data in other files to the first database file found).Note that this code just attaches the databases with the same schema.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |