SQLTeam.com | Weblogs | Forums

Exporting SQLlite to Microsoft SQL server

Want to export sqllite data to microsoft sql server. In my PC, sql server is installed.
I have sqlite.db file that I wanted in sql server(both the structure and data). I don't have any external tool to convert this data. data contain more than 90,000 rows. any help how I convert this .db file in sql server?

Welcome to forum. one way to do it, is use python. Do you have access? This is of course referencing my sqllite db. there are more ways to do this.

import sqlite3
from sqlite3 import Error


def create_connection(db_file):
    """ create a database connection to the SQLite database
        specified by the db_file
    :param db_file: database file
    :return: Connection object or None
    """
    conn = None
    try:
        conn = sqlite3.connect(db_file)
    except Error as e:
        print(e)

    return conn


def select_all_functions(conn):
    """
    Query all rows in the tasks table
    :param conn: the Connection object
    :return:
    """
    cur = conn.cursor()
    cur.execute("SELECT * FROM securityfunctions")

    rows = cur.fetchall()

    for row in rows:
        print(row)

def main():
    database = r"C:\mcc\apps\airgap-e\src\db\airgap.db"

    # create a database connection
    conn = create_connection(database)
    with conn:
        print("1. Query task by priority:")
        select_all_functions(conn)

        
if __name__ == '__main__':
    main()        

Also look at the comment section of this article

1 Like

another approach to use OPENROWSET, requires you to install sqllited ODBC driver

http://pavel.surmenok.com/2015/07/19/import-data-from-sqlite-to-microsoft-sql-server/