Convert

Convert VCF to SQL Database: Export Contacts as SQLite or SQL Script

Quick Answer

Open Univik vCard Converter, load your VCF file and select either SQLite Database or SQL Script as the export format. The SQLite option creates a ready-to-use .db file you can query immediately with any SQLite tool. The SQL Script option generates a .sql file with CREATE TABLE and INSERT statements that you can execute on MySQL, PostgreSQL, SQL Server or any SQL-compatible database. Both options preserve all contact fields including names, emails, phones, addresses, organizations and notes.

Introduction

Most VCF conversion guides cover standard formats like CSV, Excel, and JSON. But if you need to query, filter, join, or analyze contact data programmatically, a SQL database is a far better destination than a flat file. SQL gives you indexed searches across thousands of contacts, the ability to find duplicates with a single query, and the power to join contact data with other business tables like orders, tickets or transactions.

This guide covers two methods for converting VCF to SQL: the Univik vCard Converter (which offers both SQLite database and SQL script export as built-in features) and a Python script approach for developers who need a custom schema. We also cover the database schema design, useful queries for contact data, and how to import the generated SQL script into MySQL, PostgreSQL, and SQL Server.

Why Store Contacts in a SQL Database?

Converting contacts from VCF to a SQL database unlocks capabilities that flat files (CSV, Excel) cannot match.

Querying and filtering. Find all contacts at a specific company, in a particular city, or with a certain email domain using SQL WHERE clauses. With CSV you would need to open a spreadsheet and manually filter. With SQL, a single query like SELECT * FROM contacts WHERE organization = 'Acme' returns results instantly even across 100,000 contacts.

Duplicate detection. Identifying duplicate contacts in a CSV requires manual comparison or custom scripts. In SQL, a simple GROUP BY query surfaces duplicates: SELECT email, COUNT(*) FROM contacts GROUP BY email HAVING COUNT(*) > 1.

Joining with other data. If your business already uses a SQL database for orders, support tickets, or CRM data, importing contacts into the same database lets you JOIN contact records with transaction history, creating a unified view of each customer.

Application integration. Web applications, APIs, and backend services read from SQL databases natively. Storing contacts in SQLite or MySQL makes them immediately accessible to your application code without parsing VCF or CSV files at runtime.

SQLite Database File vs SQL Script: Which to Choose

Univik vCard Converter offers two SQL output formats. Choose based on your use case.

Feature SQLite Database (.db) SQL Script (.sql)
Output Single portable database file Text file with SQL statements
Ready to query Yes (open in any SQLite tool) No (must execute on a database first)
Target databases SQLite only MySQL, PostgreSQL, SQL Server, SQLite, MariaDB
Portability Single file, no server needed Text file, runs on any SQL database
Best for Local analysis, mobile apps, quick queries Server databases, web apps, team environments
File size Slightly larger (includes indexes) Smaller (text only)

Choose SQLite if you want to start querying immediately without setting up a database server. The .db file works with DB Browser for SQLite (free), the sqlite3 command line tool, Python’s built-in sqlite3 module and many other tools. No installation or server configuration required.

Choose SQL Script if you need to import the data into an existing MySQL, PostgreSQL or SQL Server instance. The .sql file contains standard CREATE TABLE and INSERT INTO statements that you can execute on any SQL-compatible database.

Method 1: Univik vCard Converter (SQLite and SQL Script)

Best for: All users. No coding required. Handles all vCard versions and field types.

Download and install Univik vCard Converter. Launch the application and load your VCF file (single-contact or multi-contact files are both supported, across vCard 2.1, 3.0, and 4.0).

In the export options, select either SQLite Database or SQL Script as the output format. The converter automatically maps VCF properties to database columns: FN becomes the display_name column, EMAIL maps to email, TEL to phone, ORG to organization, TITLE to job_title, ADR components to address fields and so on.

Click Convert. For SQLite output, the converter creates a .db file that you can open immediately in DB Browser for SQLite or query with any SQLite-compatible tool. For SQL Script output, the converter generates a .sql file containing the table schema and INSERT statements for all contacts.

The Univik converter handles the complexities that make manual VCF-to-SQL conversion difficult: multiple email addresses per contact (stored as separate rows or comma-separated values depending on schema choice), multiple phone numbers with type labels, structured addresses with components and Base64-encoded photos.

Method 2: Python Script (Custom Schema)

Best for: Developers who need a custom table schema or want to integrate the conversion into an automated pipeline.

Install the vobject library (pip install vobject) and use Python’s built-in sqlite3 module. The script below parses a VCF file, creates a contacts table, and inserts each contact as a row:

import vobject, sqlite3

Open the VCF file, iterate through each vCard component, extract the properties you need (fn, email, tel, org, title, adr, note), and insert them into the database. For contacts with multiple emails or phone numbers, you can either store the first value only, concatenate with semicolons or create a separate table for phone numbers and emails with a foreign key relationship.

The Python approach gives you full control over the schema design, data transformation, and error handling. You can normalize addresses into separate columns (street, city, state, zip, country), add custom columns (like import_date or source_file), and handle edge cases specific to your data.

Database Schema for Contact Data

A practical schema for converted VCF data balances normalization with simplicity. Here is a recommended structure:

Column Type VCF Source Notes
id INTEGER PRIMARY KEY (auto-generated) Auto-increment
display_name TEXT FN Full formatted name
first_name TEXT N (given name) Second component of N
last_name TEXT N (family name) First component of N
email TEXT EMAIL Primary email
phone TEXT TEL Primary phone
organization TEXT ORG Company name
job_title TEXT TITLE Position/role
address TEXT ADR Full address string
birthday TEXT BDAY ISO date format
note TEXT NOTE Free-text notes
url TEXT URL Website or profile link

For contacts with multiple emails or phone numbers, you have two options. The simple approach stores all values in a single column separated by semicolons (e.g., john@work.com;john@gmail.com). The normalized approach creates separate tables (contact_emails, contact_phones) with a foreign key to the contacts table. The simple approach is easier to query for basic use cases; the normalized approach is better for applications that need to search or filter by individual email or phone values.

Querying Your Contact Database

Once your contacts are in a SQL database, here are some immediately useful queries:

Find contacts by company: SELECT display_name, email, phone FROM contacts WHERE organization LIKE '%Google%'

Find duplicate emails: SELECT email, COUNT(*) as count FROM contacts WHERE email IS NOT NULL GROUP BY email HAVING count > 1

Count contacts by organization: SELECT organization, COUNT(*) as count FROM contacts GROUP BY organization ORDER BY count DESC

Find contacts without email: SELECT display_name, phone, organization FROM contacts WHERE email IS NULL OR email = ''

Search across all fields: SELECT * FROM contacts WHERE display_name LIKE '%smith%' OR email LIKE '%smith%' OR organization LIKE '%smith%'

Importing the SQL Script into Other Databases

If you exported a SQL script (.sql file), here is how to execute it on different database platforms:

MySQL / MariaDB: mysql -u username -p database_name < contacts.sql

PostgreSQL: psql -U username -d database_name -f contacts.sql

SQL Server: Open SQL Server Management Studio, connect to your database, open the .sql file (File > Open), and click Execute. Alternatively, use the command line: sqlcmd -S server -d database -i contacts.sql

SQLite: sqlite3 contacts.db < contacts.sql

Before executing, review the SQL script to verify the CREATE TABLE statement is compatible with your target database. SQLite uses TEXT for all string types, while MySQL may prefer VARCHAR(255) for shorter fields. Adjust data types if needed for your target platform.

Common Problems and Fixes

1

Special characters in names cause SQL INSERT errors. Names containing apostrophes (like O’Brien) or backslashes can break SQL INSERT statements if not properly escaped. The Univik converter handles escaping automatically. If using a custom script, ensure all string values are parameterized (using ? placeholders in SQLite or %s in MySQL) rather than string-concatenated into queries.

2

Multiple phone numbers or emails are truncated to one. If using a flat single-table schema, only the first email or phone may be stored. To capture all values, either concatenate with semicolons or use a normalized schema with separate tables for emails and phones linked by a contact_id foreign key.

3

SQLite .db file will not open in a viewer. Ensure you are using a SQLite-compatible tool like DB Browser for SQLite (free, cross-platform), the sqlite3 command line tool (included with Python and most Linux distributions), or a VS Code extension like SQLite Viewer. Regular text editors cannot open binary .db files.

4

SQL script fails on MySQL or PostgreSQL due to syntax differences. The generated script may use SQLite-specific syntax (like AUTOINCREMENT vs AUTO_INCREMENT, or TEXT vs VARCHAR). Review the CREATE TABLE statement and adjust data types and keywords for your target database before executing.

Frequently Asked Questions

Can I convert a multi-contact VCF file to a single database?

Yes. Both the Univik converter and the Python script method handle multi-contact VCF files. Each contact in the file becomes a row in the database table. A VCF file with 5,000 contacts produces a table with 5,000 rows.

Are contact photos stored in the database?

The Univik converter can store Base64-encoded photo data in a BLOB or TEXT column. For the Python method, you can extract the PHOTO property and store the binary data in a BLOB column or save photos as separate files with a filename reference in the database.

Which is better for a web application: SQLite or a SQL script for MySQL?

For production web applications with concurrent users, MySQL or PostgreSQL is better because they handle simultaneous read/write operations efficiently. SQLite is excellent for single-user applications, mobile apps, prototyping, and local data analysis. Export as SQL script if you plan to import into a server database.

Can I convert back from SQL to VCF?

There is no built-in reverse conversion in most tools. To convert SQL data back to VCF, query the database for contact records and use a script to generate VCF output. Python’s vobject library can create vCard objects from database rows and serialize them to a .vcf file.

Does the conversion preserve vCard groups and categories?

Categories (CATEGORIES property) can be stored in a text column or a separate table. Groups defined by vCard 4.0’s MEMBER property require a more complex schema with a groups table and a junction table. The Univik converter stores categories as a text field; custom grouping logic requires the Python approach.

Conclusion

Last verified: February 2026. SQLite and SQL Script export tested with Univik vCard Converter. Database import tested on MySQL 8.0, PostgreSQL 16, and SQLite 3.45. Schema tested with VCF files containing 1 to 10,000 contacts across vCard 2.1, 3.0, and 4.0 formats.

Converting VCF to SQL transforms a static contact file into a queryable, joinable, application-ready data source. Univik vCard Converter offers the fastest path with built-in SQLite database and SQL script export options that handle all VCF versions and field types automatically. For developers needing custom schemas, the Python approach provides full control over table design and data transformation. In both cases, the resulting database supports instant searches, duplicate detection and integration with existing business data that flat files simply cannot match.

Choose SQLite database if you want to query contacts immediately with no server setup. Choose SQL script if you need to import into MySQL, PostgreSQL, or SQL Server. Both options are available in Univik vCard Converter as built-in export formats. For quick analysis, open the SQLite file in DB Browser for SQLite (free) and start writing queries within seconds of conversion.

About the Author

This guide is written and maintained by the Univik team, developers of file conversion and digital forensics tools since 2013. Our vCard Converter includes SQLite and SQL script export as native features, designed for developers and database administrators who need contact data in a queryable format. Questions about VCF-to-SQL conversion? Contact our team.