Python sqlite3从现有数据库创建另一个数据库

Python sqlite3从现有数据库创建另一个数据库,python,sql,sqlite,Python,Sql,Sqlite,我有一个很大的数据集,其中需要基于某些列的值的子集。我想从这个子集创建另一个数据库。在Python中使用sqlite3如何实现这一点 The column from which I want to compare to get the subset contain date in the format of YYYYMMDD e.g. 20120429. I want to get the observation before a certain date. 另外,如何根据另一列的值wins

我有一个很大的数据集,其中需要基于某些列的值的子集。我想从这个子集创建另一个数据库。在Python中使用sqlite3如何实现这一点

The column from which I want to compare to get the subset contain date in the format of YYYYMMDD e.g. 20120429. 
I want to get the observation before a certain date.
另外,如何根据另一列的值winsorise并计算某些列的平均值

感谢

您可以将新的DB文件附加到已存在的SQLite连接,该连接已打开现有DB,然后只需使用适当的insert语句复制所需的行,并使用DB别名处理附加DB中的表:

attach 'newdb.sqlite' as newdb;

-- create table goes here if necessary

insert into newdb.table
select * from table where date < ...;
您可以将新的DB文件附加到现有的SQLite连接,该连接已打开现有的DB,然后只需使用适当的insert语句复制所需的行,并使用DB别名处理附加DB中的表:

attach 'newdb.sqlite' as newdb;

-- create table goes here if necessary

insert into newdb.table
select * from table where date < ...;

我建议你为第二部分单独提出一个问题;这与主题无关,需要单独回答。我建议你为第二部分单独提出一个问题;这与主题无关,需要单独回答。