PHPackages                             csv/csvtosql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. csv/csvtosql

ActiveLibrary[Database &amp; ORM](/categories/database)

csv/csvtosql
============

PHP class to extract data from (csv) file and transform it to (sql) file as insert statement.

1.0.0(3y ago)615MITPHP

Since Feb 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/91ahmed/CsvtoSql)[ Packagist](https://packagist.org/packages/csv/csvtosql)[ RSS](/packages/csv-csvtosql/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

**CsvtoSql** is a class that converts CSV files into SQL INSERT statements, making it easy to import data into databases like MySQL, PostgreSQL, and SQLite.

### Install via composer

[](#install-via-composer)

```
composer require csv/csvtosql
```

### Example

[](#example)

```
// Import vendor autoload
require ('vendor/autoload.php');

// Example
$csv = new Csv\Csvtosql\TransformCsv();
$csv->file('files/sales.csv') // Source csv file
    ->table('salse') // Target table name
    ->transform()
    ->exportSQL('transform/sales.sql'); // Destination (output the sql file with insert statement)
```

### Methods Description

[](#methods-description)

1- `file()`

> Specify the source csv file path you need to transform.

```
// @param string (csv source file path)
file('folder/file.csv');
```

2- `table()`

> Set the target table name; the first CSV row is used as column names.

```
// @param string (table name)
table('tablename');
```

3- `transform()`

> Extract data from (csv) and transform it to (sql).

4- `exportSQL()`

> Generate a new SQL file containing the transformed data as well-structured INSERT statements, ready for integration into your database.

```
// @param string (new sql file destination)
exportSQL('exported/file.sql');
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please fork the repository and submit a pull request.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

By incorporating these sections, the `README.md` will provide a comprehensive overview of the CsvtoSql library, guiding users from installation to implementation effectively.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1243d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44722367?v=4)[Ahmed Hassan Hassan](/maintainers/91ahmed)[@91ahmed](https://github.com/91ahmed)

---

Top Contributors

[![91ahmed](https://avatars.githubusercontent.com/u/44722367?v=4)](https://github.com/91ahmed "91ahmed (19 commits)")

---

Tags

csvcsv-convertercsvtosqlphpsql

### Embed Badge

![Health badge](/badges/csv-csvtosql/health.svg)

```
[![Health](https://phpackages.com/badges/csv-csvtosql/health.svg)](https://phpackages.com/packages/csv-csvtosql)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
