Design connection to motor shaft for printed gear
Design a different connection to the shaft, however I don't know of any

Use a shaft/flange coupler to be fastened to your shaft and to your printed part.

Without knowing the length of the shaft, you could connect a flange/coupler to design this into your gear. This is a good solution if you have to transmit larger torques. See e.g. this pulley that incorporates that concept.
Shaft flange couplers can be connected to your printed part and to the flat part of the shaft.
Metal flange couplers are available in many sizes:

A recess in the printed part houses the flange:

When assembled you can mount the pulley/gear onto the shaft, provided you have enough length on the shaft.